#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11138205 use warnings; open my $fh, '<', \<Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... Only the... END print sort { my ($anum, $achars, $bnum, $bchars) = map //, $a, $b; $achars cmp $bchars || $anum <=> $bnum } <$fh>;