use Regexp::Assemble; my $patterns = "/path/to/file.txt"; my $list_regex = Regexp::Assemble->new(file => $patterns); $list_regex->track( 1 ); open( FILE, "<", "$arg1") or die "$arg1: $!\n"; while () { if (/$list_regex/) {print "\n$arg1\n$list_regex->matched\n";} } close(FILE); }