SPUG: Filehandes -- slurping up the files in \folder\*.htm?

Greg Mushen greg.mushen at gettyimages.com
Wed Feb 9 19:49:37 CST 2000


Hi Sean,
 
To process all the files in a directory, your code should go something like
this:
 
# This will open the directory
opendir(DIR, "<your-dir>") or die "Can't open dir: $!\n";
 
# This will go through each file in that directory.
while(defined ($file = readdir(DIR))) {
            open(FILE, "$file");
            do whatever else here
}
 
If you wanted to add functionality so that it only processes it when it has
been changed, you'd have to figure out how you wanted to approach it.  You
could get really complex or just check the modification time of the file and
process it if it is greater than 10 min or so using the -M file test switch.
 
Hope this helps,
Greg

-----Original Message-----
From: Sean Owens (Entex) [mailto:a-seano at microsoft.com]
Sent: Wednesday, February 09, 2000 4:52 PM
To: SPUG (E-mail)
Subject: SPUG: Filehandes -- slurping up the files in \folder\*.htm?


I'm sure there's a very simple answer, but I'm still a bit new at this perl
stuff...
 
I want to sequentially read in all the files in a directory (there aren't
_that_ many, but I'm lazy and don't want to create a hash with all the
filenames listed), munge them, and save them out (then open the next one...
etc.).  Can I assign a variable to a filename on a server, or can I open it
some other way?  In this case my script always runs, and always processes
the files every 5-10 mintues
 
Even better, I'd like to have the munging happen only on change, so my
script always runs and only processes whenever necessary.  Now I'm really
out of my depth!
 
To make this even more fun (as you might guess from my email), I'm on a
Win32 system.
 
Can anyone point me in the right direction to get me started?  thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20000209/22deddd2/attachment.htm


More information about the spug-list mailing list