Drieux wrote: > > On Wednesday, April 3, 2002, at 01:09 , Allison Ogle wrote: > [..] > > However, if I didn't know the name of the datafile how would I open it? I > > tried $inputFile="(*).dat"; and $inputFile="*.dat"; but neither works. > > Does anyone have any ideas? Thanks, > > ### #!/usr/bin/perl > ### > ### use strict; > ### > ### my $dir ='.'; > ### my $suffix = '.txt'; > ### opendir(THEDIR, $dir) or die "unable to read $dir:$!"; > ### my @allfiles = grep { $_ =~ /$suffix/ } readdir THEDIR; ^^^^^^^^^ This interpolates to /.txt/ which will match file names like "sometxt.doc", "othertxt", "any-old-file-with-txt-in-it", etc.
> ### closedir THEDIR ; > ### > ### > ### print "found file $_\n" foreach (@allfiles); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]