#!/usr/bin/perl use warnings; use strict; use feature qw(say); my @strings = qw(xxxxxx.2012-50.yyyyy xxxxxx.2012-51.yyyyy xxxxxx.2012-52.yyyyy xxxxxx.2013-1.yyyyy xxxxxx.2013-2.yyyyy xxxxxx.2013-3.yyyyy xxxxxx.2013-4.yyyyy xxxxxx.2013-10.yyyyy xxxxxx.2013-11.yyyyy ); my @sorted = sort { my ($ay, $an) = $a =~ /\.([0-9]+)-([0-9]+)\./; my ($by, $bn) = $b =~ /\.([0-9]+)-([0-9]+)\./; $ay <=> $by or $an <=> $bn } @string; say for @sorted;