in reply to Why am I getting message «Operation "<=>": no method found,» ?
Hello RCH,
As 1nickt says, when $demo has the value 'problem', each element of %distance is a Class::Measure::Length object. So the following fix should work:
... print "\nAnd here comes the result of sorting the keys of that has +h\n"; my $sort_function = ($demo eq 'problem') ? sub { $distance{$b}->value <=> $distance{$a}->value } : sub { $distance{$b} <=> $distance{$a} }; for my $place (sort $sort_function keys %distance) { printf "%10s is %25.15f km from here\n", $place, $distance{$pl +ace}; } }
(Note that Class::Measure::Length inherits most of its methods from Class::Measure.)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|