The answer from Abigail-II above is correct. In case you're wondering what an "openddir/readdir wrapper" is, it's a loop like this:
Another common idiom is to use grep to pull out the entries you want first, although this will consume memory proportional to the number of files and the lengths of their names.chdir $the_directory or die "Couldn't chdir to $the_directory: $!"; opendir(D, ".") or die "Couldn't open . ($the_directory): $!"; while ($file = readdir D) { next unless $file =~ /\.las$/; # other logic later... } closedir D;
Note, both of those code samples are untested.chdir $the_directory or die "Couldn't chdir to $the_directory: $!"; opendir(D, ".") or die "Couldn't open . ($the_directory): $!"; my @files = grep { /\.las$/ } readdir D; closedir D; foreach my $file (@files) { # whatever... }
HTH
In reply to Re: File glob question
by VSarkiss
in thread File glob question
by licking9Volts
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |