kepler has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Need help with a script
by toolic (Bishop) on May 27, 2011 at 13:10 UTC
Re: Need help with a script
by Fletch (Bishop) on May 27, 2011 at 13:08 UTC

    man 1 sort. Or show some effort and post what Perl you've already written that's not working and explain what's not doing what you expect.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Need help with a script
by jffry (Hermit) on May 27, 2011 at 14:24 UTC
Re: Need help with a script
by lidden (Curate) on May 27, 2011 at 14:22 UTC
    You want something like this (untested):

    my @sorted = sort {my @A = (split '\|', $a)[4, 5]; my @B = (split '\|', $b)[4, 5]; $A[0] cmp $B[0] || $A[1] <=> $B[1]} @unsorted;

    Update: Fixed bug pointed out by chromatic below.

      untested

      Trivial bug: splits first operand is a regular expression, not a string, so you need to escape the alternation metacharacter. I used to make that mistake all the time too.

Re: Need help with a script
by Anonymous Monk on May 27, 2011 at 21:01 UTC