in reply to Re: Classic Sort Algorithm
in thread Classic Sort Algorithm

I'm not sure what it means when it refers to field1($a). When I insert this into my code I get a Undefined subroutine &main::field1 called at error.

Replies are listed 'Best First'.
Re^3: Classic Sort Algorithm
by 7stud (Deacon) on Jun 21, 2011 at 00:12 UTC
    I'm not sure what it means when it refers to field1($a). When I insert this into my code I get a Undefined subroutine &main::field1 called at error.
    Yes. It was left to the reader, you, to define a method that extracts field1 from a line of data. Maybe calling the function get_field1() would have been clearer.

    Note that when perl sorts a group of things it has to compare each thing to the other things in the group many times. When comparing things perl assigns two of the things to the global variables $a and $b.