http://qs321.pair.com?node_id=1208835


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:  <%-{-{-{-<