in reply to Identifiying unique pattern

I have interpreted the question as follows: Given a set of file names in an array, find the number of files that share the same alphanumeric prefix so that I know how many files I will be deling with when I use $prefix* as a glob.

I have added to the data to illustrate the point.

my @str= qw(ssg.nal ssg_00.nsr ssg_00.nsn ssg_00.nss xxx_01.txt xxx_0 +3.dat); my %starts; foreach (@str) { #increment the value for the hash element that has the #prefix as a key. $starts{$1}++ if /^([a-zA-Z0-9]+)/; } # print all the prefixes and number of files associated foreach (keys %starts) { print "$_ = $starts{$_}\n"; }
gives
ssg = 4 xxx = 2

Let me know if this is what you had in mind.