Phoenix.pm: Glob limit
Kevin Buettner
kev at primenet.com
Fri Oct 22 17:20:37 CDT 1999
On Oct 22, 3:06pm, Giffin Ron-P08295 wrote:
> I don't believe opendir,... will help. I get the errors when I
> use the unix wildcard * IE:
> @files = `ls *.dat` ; or @files = glob ( "*.dat" ) ; or even
> foreach $file ( <*.dat> ) { ... } I will look at file::find.
I did say I was partial to File::Find, but in this case opendir/
readdir/closedir might be better. (Unless you need to traverse
a directory structure in which case File::Find would probably be
better.)
Try this:
--- test-opendir.pl ---
#!/usr/bin/perl -w
opendir DIR, '.' or die "Can't open .: $!";
@files = grep /.dat$/, readdir DIR;
closedir DIR or die "Can't close .: $!";
print join "\n", sort @files;
print "\n";
--- end test-opendir.pl ---
--
Kevin Buettner
kev at primenet.com, kevinb at cygnus.com
More information about the Phoenix-pm
mailing list