my @sorted = map { s/(^|\D)0+(\d)/$1$2/g; $_ } sort
map { /(\d+)/sprintf("%06.6d",$1)/ge; $_ } @arr;
will sort your array naturally. Also I noticed the fact there's no test5 element in your initial description, but tes5 instead
to be explained this could be divided into parts. since Perl interpreter crawls expressions right to left first action is
my @sorted = map { s/(\d+)/sprintf("%06.6d",$1)/ge } @arr;
here we add zeroes between text and numbers to have 6 decimal places (this is a random number, may be any that satisfies current task)
then we sort the array lexically
@sorted = sort @sorted
an then remove inserted zeroes
@sorted = map { s/(^|\D)0+(\d)/$1$2/g } @sorted;
among main caveats - this will break elements like 'test04'