[pm-h] simple perl directory+file task

Russell L. Harris rlharris at oplink.net
Tue Oct 2 08:00:44 PDT 2012

I am looking forward to the meeting on the 11th.  It is simple tasks
of the following sort which I hope the presentation is going to teach
me how best to approach:

SITUATION: A directory "datafiles/" contains files named "red.doc",
"green.dat", "yellow.tex", "blue.txt", etc.

NEED:  Open each file in the directory, and append to the end of each
file the file name, so that file "red.doc" reads:

     <existing text, if any>

file "yellow.tex" reads:

     <existing text>

and so forth. 

Of course, the next step is recursion into sub-directories.  From my
reading I think I see how to handle recursion, but obtaining the
filename and stepping through a directory is the immediate hurdle.  

It seems to me that the books and tutorials typically do not spend
enough time explaining the fundamental concepts.


More information about the Houston mailing list