Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: creating qr from existing regex

by AnomalousMonk (Chancellor)
on Feb 09, 2018 at 14:47 UTC ( #1208835=note: print w/replies, xml ) Need Help??


in reply to Re^4: creating qr from existing regex
in thread creating qr from existing regex

c:\@Work\Perl\monks>perl -wMstrict -le "my $string = '/.*u\/ba$/i'; ;; my $rx = eval 'qr' . $string; print $rx; print 'A: match' if 'u/Ba' =~ $rx; ;; my $ry = qr{ \A foo $rx }xms; print $ry; print 'B: match' if 'foolubatU/bA' =~ $ry; " (?i-xsm:.*u/ba$) A: match (?msx-i: \A foo (?i-xsm:.*u/ba$) ) B: match

Update: Of course, given that you're dealing with user-supplied data and considering the danger of an injection attack, maybe one should think twice about an eval-based approach.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1208835]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-07-19 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (398 votes). Check out past polls.

    Notices?