in reply to Re: Sorting Files with Numbers
in thread Sorting Files with Numbers
I'm guessing that 'file' was just an example of a name that the orginal poster was using. It isn't very likely that the filenames will be exactly 4 chars long followed by a number. This will probably work better (untested):
sub file_sort { $a =~ /(\d*)$/; my $a_num = $1; $b =~ /(\d*)$/; my $b_num = $1; $a_num <=> $b_num; } foreach my $file (sort &file_sort keys %hash) { print "$key \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Sorting Files with Numbers
by dmmiller2k (Chaplain) on Dec 31, 2002 at 15:08 UTC |