in reply to Sorting array

Hello negativ_m. FYI sort in computing is most of the time used to mean order (eg: from smallest to bigest). Here it rather looks like you want to select some elements out of your list. In your case, you want an unique file for each number. In perl, there's one thing that does uniqueness well: hashes. You could do something like:

use Data::Dumper; my %uniq; for my $file (@ar1) { my ($number,) = $file =~ /(\d+)/; $uniq{$number} = $file; } print Dumper \%uniq; my @values = values %uniq;
This will not do exactly what you want, you'll have to add a condition to only replace the value in $uniq{$number} if the current file has a higher letter than the one already stored. You can compare two strings with gt and lt. eg: "text2g.txt" gt "text2a.txt".