It's not clear whether your "...and so on"
means that you want to grab several pieces
of information from each filename or whether you just
mean more filenames with one thing to grab each time.
To take the case that the others have not answered so
far, let's assume for a moment that the number of digits is always
exactly the same each time
and that you want to retrieve several bits
of data from the filename. Try a regex. Long form:
use strict;
my ($this, $that, $tother, $twix);
my $fname = "0092042095432.dat";
if ($fname =~ /^(\d{4})(\d{3})(\d{3})(\d{3})/) {
($this, $that, $tother, $twix) = ($1,$2,$3,$4);
}
print "$this $that $tother $twix\n"; # ...or whatever
Or... more succinctly and idiomatically:
($this, $that, $tother, $twix)
= $fname =~ /^(\d{4})(\d{3})(\d{3})(\d{3})/;
print "$this $that $tother $twix\n"; # ...or whatever
|