use strict; use warnings; my @array = (-11,-13,4, 22, 17); print find_max_odd(@array), "\n"; sub find_max_odd { my $max; while ($max = shift) { last if $max % 2; } return "Not found" unless @array; while (my $current = shift) { next unless $current % 2; if ($current > $max) { $max = $current; } } return $max; }