O'Reilly logo
  • Michael Schreckengost thinks this is interesting:

sub max ( $max_so_far, @ ) { foreach (@_) { if ($_ > $max_so_far) { $max_so_far = $_; } } $max_so_far; }

From

Cover of Learning Perl, 7th Edition

Note

This subroutine, as written, does not handle negative values. To fix, add the following statement before the foreach loop:
$max_so_far = shift(@_);
This initializes the high water mark to the first element in the array prior to starting the loop.