Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: One line assigment statement with regex match

by ketema (Scribe)
on Jun 23, 2005 at 15:37 UTC ( #469429=note: print w/replies, xml ) Need Help??


in reply to Re: One line assigment statement with regex match
in thread One line assigment statement with regex match

I get search pattern not terminated when I try this:
my $re = qr/(?:${\( join "|", map { qr/\Q$_\E/ } @terms )})/;

Replies are listed 'Best First'.
Re^3: One line assigment statement with regex match
by mugwumpjism (Hermit) on Jul 06, 2005 at 22:07 UTC

    Terribly sorry, I didn't test it.

    Yes, the double use of "/" to delimit regular expressions is tripping up the parser. Much better to use braces;

    @terms=qw(foo bar b.*az); my $re = qr{(?:${\( join "|", map { qr{\Q$_\E} } @terms )})}; print "$re\n";

    The above will print "(?-xism:(?:(?-xism:foo)|(?-xism:bar)|(?-xism:b\.\*az)))"

    $h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://469429]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2020-05-25 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (146 votes). Check out past polls.

    Notices?