my $filename = shift @*ARGS or die "You need to pass in a filename."; #### sub MAIN($filename) { # rest of the mainline code here } #### sub natural_cmp ($a, $b) { my ($first, $second) = ($a, $b); my ($one, $two) = ($first, $second).map({ .=subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", 0, $0.chars, $0) }, :g).lc }); return ($one cmp $two); } #### sub natural_cmp ($a, $b) { my ($one, $two) = ($a, $b).map(*.subst(/(\d+)/, -> $/{ sprintf( "%s%c%s", 0, $0.chars, $0) }, :g).lc); return $one cmp $two; }