my $regex = join '|', @latin_am; while (<>) { print $1 if /$regex/; } #### % foo.pl file