in reply to Sorting Hash: Sort Criteria Moved Into Eval
I also only see the problem on 5.6.1 and not on 5.8.4, which suggests it is a bug that has been fixed.
The cause is that (in 5.6.1) the values of $a and $b are undef inside eval.
Which makes every eval produce a "Use of uninitialized value in numeric comparison (<=>) at (eval 1) line 1." when warnings are enabled.
(And unhelpfully, a segfault under strict!).
The sort order that you see after the evaled version is probably just the natural key iteration order as no sort has taken place.
Use warnings (-w) chalks up another victory :)
ps. There has to be a better way than using eval in a sort block.
|
|---|