@x = qw( 5xxx 2xxx 300x 10xx ); @x = sort {my ($y) = $a =~/^(\d+)/; my ($z) = $b =~/^(\d+)/; $y <=> $z} @x; print "regex sort: @x\n";