defined-or cache, needs defined-or (dor) operator introduced in 5.10my @sorted = sort { ( $times{$a} //= expensive_call($a) ) <=> ( $times{$b} //= expensive_call($b) ) } @old_array;
See also Resorting to Sorting, Sorting problem with Orcish Manuever
In reply to D'Orcish Maneuver by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |