in reply to Re: Find a list of numbered files with same basename
in thread Find a list of numbered files with same basename

Using glob makes it very simple to generalize this to find any pattern you want.
my $pattern = "*.[0-9][0-9]"; my @file_names = glob $pattern;
for instance, would find all files that ended with a double digit number.

To bad the glob format isn't quite as nice as the full regular expression engine, I'd have liked to be able to do \d+, but without further complicating this, we can't.

-Scott

Replies are listed 'Best First'.
Re^3: Find a list of numbered files with same basename
by mnlight (Scribe) on Apr 22, 2005 at 19:51 UTC
    Why is this not returning anything? The files exit the format is correct but glob does not populate the array.
    sub find_files{ my ($dir, $db, $table) = @_; my $file = "$dir" ."/" . "$db.$table.[0-9][0-9]"; print "$file\n"; my @files = glob $file; foreach my $found_file (@files){ print "$found_file\n"; } return @files; }
      we need to know how you are calling find_files and your dir structure to see what's going wrong. What's the output from the 'print "$file\n"' line?