> -----Original Message-----
> From: Jon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 2:03 PM
> To: [EMAIL PROTECTED]
> Subject: File Handling question - easy
> 
> 
> I don't know if I sent my first email correctly.  Sorry for 
> the repeat if I 
> did, I'm new :)
> 
> Hello,
> The code below takes all files in my current directory that 
> have filenames 
> ending with ".txt". Using this stuff I can loop through those 
> files and do 
> what I need to do.
> 
> My problem is, I want to do this for a bunch of different 
> patterns (ex. 
> ".txt", ".this", ".that"). How can I make what is inside the 
> angle brackets 
> a variable? I've tried to use eval to build my while 
> statement and I can't 
> make it work. Help Please?
> 
> while(<*.txt>)
> {
> ### do stuff, given a filename
> }

Use glob():

   my $patterns = '*.txt *.this *.that';
   for (glob($patterns)) { ... }

P.S. I'm surprised this works with while(). I didn't realize fileglobs
were magical inside while(), but it appears they are... Is this documented?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to