Hi Martin,

Just use grep in combination with readdir:

 # Name your directory here
 my $path = 'Macintosh HD:Desktop Folder';

 # Create a directory handle
 opendir DIR, $path;

 # Read the contents of our directory,
 # filtering in those that match /^result\d{3}/
 my @contents = grep {
   /^result\d{3}/
 } readdir DIR;

 # Close the directory handle
 closedir DIR;

 # Print directory contents
 for my $file ( @contents ) {
   print "$file\n";
 }

Cheers,
David

At 7/12/2003 9:35 AM, Martin Buchmann wrote:

> Hi all,
> 
> i think i just need an idea or a function's name, respectively. I
> want the user to select a folder with the StandardGetFolder Dialog,
> that's easy and working but than i want my script to get all files in
> that folder which have a specific name, say /^result\d{3}/.
> 
> I'm sure this is easy done but i don't know how 8-) Is there a
> function which returns a list of specific files in a given directory?
> I checked the MacPerl book and the file related pods quickly but
> found nothing.
> 
> Any ideas will be apreciated.
> Martin

Reply via email to