#!/usr/bin/perl use strict; use warnings; use feature "say"; my @unsorted_array = qw( page1.html page11.html page2.html page3.html ); say for sort { ($a =~ /([0-9]+)/)[0] <=> ($b =~ /([0-9]+)/)[0] } @unsorted_array;