W
Wes Groleau
I put a bunch of records in a hash. I need to output a subset
of the records, so I make a list of the keys needed. Output order
is not important EXCEPT that a certain key must always be first,
and a certain key last.
# here $Keys[0], $Keys[1], $Keys[5] all contain text
@Keys = sort
{
if ($a eq "HEAD") {return -1};
if ($b eq "HEAD") {return 1};
if ($a eq "TRLR") {return 1};
if ($b eq "TRLR") {return -1};
return 0;
} @Keys;
# here $Keys[0], $Keys[1], $Keys[5] are all undefined
Several variations on the style of the comparison black
all gave the same result. Assigning the sort to a different
array left the result array empty also.
What am I missing?
RTFM references OK,
as long as they're not 'perlfunc' or "Perl Cookbook"
of the records, so I make a list of the keys needed. Output order
is not important EXCEPT that a certain key must always be first,
and a certain key last.
# here $Keys[0], $Keys[1], $Keys[5] all contain text
@Keys = sort
{
if ($a eq "HEAD") {return -1};
if ($b eq "HEAD") {return 1};
if ($a eq "TRLR") {return 1};
if ($b eq "TRLR") {return -1};
return 0;
} @Keys;
# here $Keys[0], $Keys[1], $Keys[5] are all undefined
Several variations on the style of the comparison black
all gave the same result. Assigning the sort to a different
array left the result array empty also.
What am I missing?
RTFM references OK,
as long as they're not 'perlfunc' or "Perl Cookbook"