use strict; use warnings; my ($x, $y, $z) = (-11,-13,4); my $max; for($x,$y,$z) { # next unless $_ % 2; if ($_ % 2) { $max = $_ unless defined $max; $max = $_ if $max < $_; } } print "max odd: ", $max || "not found","\n"; #### use strict; use warnings; my ($x, $y, $z) = (-11,-13,4); my $max = 0; if($x % 2) { if ( ! $max ) { $max = $x; } elsif ($max < $x ) { $max = $x; } } if($y % 2) { if ( ! $max ) { $max = $y; } elsif ($max < $y ) { $max = $y; } } if($z % 2) { if ( ! $max ) { $max = $z; } elsif ($max < $z ) { $max = $z; } } print "max odd: ", $max || "not found","\n";