Help for this page

Select Code to Download


  1. or download this
    my $filename = shift @*ARGS or die "You need to pass in a filename.";
    
  2. or download this
    sub MAIN($filename) { 
        # rest of the mainline code here 
    }
    
  3. or download this
    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);
    }
    
  4. or download this
    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;
    }