P is for Practical | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Recently in one of my projects, I need to put the stringified Regexp object into code. For example, I have: $re = qr(/); which stringifies into (in Perl 5.14): (?^u:/) I then need to generate some Perl code (later to be eval()-ed) to test data against this regex: $code = "if (\$data =~ qr/$re/) { blah() }"; Currently I just do this: $re = "$re"; $re =~ s!/!\\/!g; I'm wondering if this is generally safe for the various regexes, or are there edge cases which I missed? In reply to Putting the stringified Regexp object into code by sedusedan
|
|