#!/usr/bin/perl -wT use strict; my @arr = 1..10; my $tofind = 5; my $found; { grep {$_ == $tofind and $found = 1 and last} @arr; # wont get here if element is found; } print $found ? "I found" : "I didn't find", " element $tofind\n";