Perl directories - How to work on each file in a directory
Perl file and directory FAQ: I'm often asked a question like this: "How do I do fill_in_the_blank for each file in a directory?"
I'll leave the "fill in the blank" part up to you. I've seen the need to do many things to every file in a directory - print each file, change one line in every file, rename the file - whatever. The cool part is that it's very easy to accomplish these tasks with Perl.
Here's a snippet of Perl code that prints a listing of every file in the current directory: