in reply to List::Util max with block

my ($max) = map $_->[0], reduce { $a->[1] > $b->[1] ? $a : $b } map [ $_, complex_calculation($_) ], LIST;

Update: Added missing parens around LHS of assignment

Replies are listed 'Best First'.
Re^2: List::Util max with block
by ikegami (Patriarch) on Nov 06, 2009 at 20:06 UTC
    Alternative:
    my $max = shift(@list); my $max_c = complex_calculation($max); for (@list) { my $c = complex_calculation($_); if ($c > $max_c) { $max = $_; $max_c = $c; } }
      Thanks ikegami,

      These are both excellent suggestions.