in reply to Perl regex question

You might want to look at Regexp::Assemble.
perl -MRegexp::Assemble -e ' $ra=Regexp::Assemble->new; $ra->add($_) for qw(list of words); local $/=undef; # slurp mode on $re=$ra->re; # create a regex from your list of words while(<>){ print "$1 in $ARGV\n" if $_ =~ m{($re)} }' list of files

print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});

Replies are listed 'Best First'.
Re^2: Perl regex question
by ikegami (Patriarch) on Mar 08, 2009 at 16:04 UTC

    Note quite. That should be

    $ra=Regexp::Assemble->new; $ra->add(quotemeta($_)) for qw(list of words); $re=$ra->re;

    or

    $re=Regexp::List->new->list2re(qw(list of words));

    since you start with a list of words, not a list of patterns.