in reply to Helping with sorting

On a side note, I couldn't help but notice that these lines probably aren't doing what you think:
my @sorted = join("\n", sort {$b <=> $a} @array); print foreach @sorted;
What it looks like you want is for @sorted to be a list of your sorted values, which at the moment, it's not...

When you use join(), it returns a single scalar with your list values delimited by the characters you specify.

Try:
my @array = qw(2aa 2ba 12kf 9cn 9vn 21sg); my @sorted = join("\n", sort {$b <=> $a} @array); print $#sorted; # Prints the index of the last element in the array @sorted = sort {$b <=> $a} @array; print $#sorted;
And you'll see what I mean.