in reply to sorting an array

Sort::Key::Natural seems the best way here, so I'd stick with moritz's suggestion.

But if you want to experiment with sort, it can be done with a custom sort subroutine. An example (tested):

#!/usr/bin/perl -w use strict; sub by_the_number_at_the_end { $a =~ /(\d+)$/; my $end_of_a = $1; $b =~ /(\d+)$/; my $end_of_b = $1; return -1 if $end_of_a < $end_of_b; return 0 if $end_of_a == $end_of_b; return 1 if $end_of_a > $end_of_b; } my @array=("ch1","ch11","ch2","ch5","ch55","ch16"); print join ("\n", sort by_the_number_at_the_end @array);

Regards,
Luke