use strict; use warnings; my @array = ( -11, -13, 4, 22, 17); print "Result: ",find_max_odd(@array) // "undefined", "\n"; sub find_max_odd { my $max; for (@_) { next unless $_ % 2; unless ( defined $max ) { $max = $_; next; } $max = $_ if $_ > $max; } return $max; } #### use strict; use warnings; my @array = (-11,-13,4, 22, 17); print find_max_odd(@array), "\n"; sub find_max_odd { my $max; while (my $current = shift) { next unless $current % 2; if (not defined $max or $current > $max) { $max = $current; } } return $max // "undefined"; }