    #!/usr/bin/perl
    # sort flat file by employee name starting in column 8
    #
    sub byName { ((substr $a, 8, 12) cmp (substr $b, 8, 12)); }
    
    # initialize loop counter
    $i = 0;
    
    # read input file into array of rows
    while (<>) { $filerecs[$i++] = $_; }
    
    # sort the array of rows using name sort into sorted_recs array
    @sorted_recs = sort byName @filerecs;
    
    # write sorted array to standard output
    foreach $line (@sorted_recs) { print $line; }
