my $regex_string = join '|', @list_patterns; open( FILE, "<", $arg1 ) or die "$arg1: $!"; $_ = do { local $/; }; # temporarily set $/ = undef to slurp file close FILE; if ( /($regex_string)/is ) { # got a match... }