#Note this code still won't work - see sherm's explanation below. foreach my $name (@myNames) { if($name =~ "jackson") print $name . "\n"; #sic - should be { print $name . "\n" } }