Help for this page

Select Code to Download


  1. or download this
    #!/usr/local/bin/perl -w
    
    use strict;
    ...
    a|b|c|10
    d|e|f|100
    g|h|i|2
    
  2. or download this
    Argument "|10\n" isn't numeric in ncmp at tmp.pl line 9, <DATA> chunk 
    +3.
    Argument "|100\n" isn't numeric in ncmp at tmp.pl line 9, <DATA> chunk
    + 3.
    Argument "|100\n" isn't numeric in ncmp at tmp.pl line 9, <DATA> chunk
    + 3.
    ...
    a|b|c|10
    d|e|f|100
    g|h|i|2
    
  3. or download this
    my @sorted = map $_->[1],
                 sort { $a->[0] <=> $b->[0] }
                 map [ substr($_,rindex($_,'|')+1), $_ ],
                 @database;
    
  4. or download this
    my $width = 10;  # must be at least as big as the longest field being 
    +compared
    my @sorted = map substr($_, index($_, '|')+1),
                 sort
                 map sprintf("%0${width}d|%s", substr($_,rindex($_,'|')+1)
    +, $_),
                 @database;