use strict; use warnings; use List::MoreUtils qw(any); my $file ="/pathtofile/file.txt"; open (FILE, $file) or die $!; my @typedefs = qw(acuser, replica_sync_cmd, 2015/01/13); while ( my $line = ) { if ( any { $line =~ /$_/ } @typedefs ) { # perform various actions here if line match print $line; } }