in reply to Sorting Criteria
You don't return the elements from the sort block, you return -1, 1 or 0 depending on whether $a or $b was greater or they were equal. See perldoc -f sort.
-
You don't need to pass $a / $b explicitly that way, they're special globals.
In fact, you even shouldn't, since $a / $b are aliases, and you're reassigning to them a copy of their value at the top of your block. Alternatively, assign them to lexicals named differently from $a / $b. In your case, I'd just drop the shifts, call the function by_date and then say
@sorted = sort &by_date keys %reversed;
Makeshifts last the longest.
|
---|
In Section
Seekers of Perl Wisdom