my @list = qw /foo bar foo/; for my $x (1, 2) { for (@list) { if (/foo/) { # Assume a 'once-only if' print "foo"; } } }