#!/usr/local/bin/perl -w use strict; sub dictionary { dictionary_case(lc $a,lc $b) || dictionary_case($a,$b) } sub dictionary_case { my @a = split /(\d+)/, $_[0]; my @b = split /(\d+)/, $_[1]; my $lex = 1; for(;;) { my $x = shift @a; my $y = shift @b; if (! defined $x) { return -(defined $y); } elsif (! defined $y) { return +1; } my $c = $lex ? $x cmp $y : $x <=> $y; $lex = !$lex; return $c if $c; } return 0; } print join "\n", sort dictionary (qw(X10y x9y x bigboy y x11y bigbang bigBoy)), "\n";