On Wednesday, April 3, 2002, at 01:43 , John W. Krahn wrote:
> 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'; >> ### 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. the fix would then need to be say my @allfiles = grep { $_ =~ /\.${suffix}$/ } readdir THEDIR; Good Eyes! >> ### closedir THEDIR ; >> ### >> ### >> ### print "found file $_\n" foreach (@allfiles); My Complements... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]