Use the grep function to search through your list..
foreach ( sort (grep /^123/, readdir(WD)) ) {
#use $_ here
}
-----Original Message-----
From: Margaret Quinn [mailto:marg...@lerltd.com]
Sent: Wednesday, June 21, 2000 7:49 AM
To: perl...@listserv.activestate.com
Subject: Parsing directory for particular filenames
The method of sending a mail to this list has changed - i hope i am posting
this to the correct place.
I would like to search through a directory of filenames look for particualry
files that match my criteria and display them as hyperlinks.
So far i have :
opendir(WD,"C:/test/GraphList") || die "Cannot opendir . (Failed to open
directory): $!";
foreach (sort readdir(WD))
{
print qq|<a href="C:/test/GraphList/$_">$_</a><br>\n| unless /^\.\.?$/;
print qq!$filename\n!;
}
closedir(WD) || die "Cannot closedir . (Failed to close directory): $!";
This is printing out the entire listing of files in the directory - however
i want to take this one stage further and only
list those files in the direcory begining with a certain code such as 123.
So if there was 123.jpg, 1234.jpg, 12377.jpg these 3 files would be listed.
Has anyone done something like this before that could post me some code to
help me out.
Thanks in advance