use DirHandle;
my @files = ();   # your array to hold the files found

my $PATH = "<path_to_your_folder>";
opendir DIR, $PATH or die "Unable to open ".$PATH." folder!";

#  put your pattern here following the grep command, 
#  this pattern gets *.dat files from $PATH
@files = grep /\w+\.(dat)/, readdir DIR;
   
if ($#files < 0 ) {
   print "No files.\n";
  } else {
   print "There are files.\n\n";
} # if ($#files < 0 )

Hope this helps...
Cary Penington
Senior Oracle DBA
McKesson Prospective Health


-----Original Message-----
From: Don Mathews [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 4:05 PM
To: [EMAIL PROTECTED]
Subject: List files


Hello:

I need to list all the files matching a pattern in a directory.Can anyone
provide an example to do that.

eg. 
I would do $target_dir/bin/ls $foo.*.dat in UNIX.

I want to do the same thing in perl and just store the names of all the
$foo.*.dat files in a temporary array which I can manipulate.

Rgds.





_____________________________________________________________
Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus

Reply via email to