If you want order, you need an array - hashes are unordered. As you're
using count as keys, you can sort them (make its a numeric sort) but just
push your hash on to an array (an "AoH") instead:
while( my $f = readdir( DIR )) {
next if( $f eq '.' or $f eq '..' );
my($template) = ($f =~ /(\d+[A-Z][A-Z]*)[0-9]*/);
my($tracename) = ($f =~ /\d+([A-Z][A-Z]*[0-9]*)[a-z]/);
...
my %trace_info;
$trace_info{'template_id'} = $template;
$trace_info{'trace_name'} = $tracename;
$trace_info{'trace_file'} = $tracefile;
$trace_info{'trace_format'} = $traceformat;
$trace_info{'trace_end'} = $tracedirection;
push @trace_info_hashes, \%trace_info;
}
Note, you are doing:
while( my $f = readdir( DIR )) {
$count++;
next if( $f eq '.' or $f eq '..' );
which means you'll have holes in your list - the $count for '.' and '..'
will be empty. And I gather you're confident that:
my($template) = ($f =~ /(\d+[A-Z][A-Z]*)[0-9]*/);
my($tracename) = ($f =~ /\d+([A-Z][A-Z]*[0-9]*)[a-z]/);
always match? The phrase:
[A-Z][A-Z]*
is:
[A-Z]+
and:
my($template) = ($f =~ /(\d+[A-Z][A-Z]*)[0-9]*/);
is the same as:
my($template) = ($f =~ /(\d+[A-Z]+)/);
the '+' will get all the A-Zs and that's what you're capturing. Testing
for zero or more digits afterwards isn't going to change anything (unlike
the 2nd "tracename" match, where you capture those *and* want to stop on a
lower letter).
a
Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
End of the beginning
Jan. 19. 1812: Luddites torch Oatlands Mill in Yorkshire, England. 1857
_______________________________________________
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs