Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^2: Regex variables with delimitersby clerew (Novice) |
on May 19, 2019 at 15:11 UTC ( [id://11100256]=note: print w/replies, xml ) | Need Help?? |
Yes that works, but my copy pf the O'Reilly Camel book seems to suggest otherwise :-(. Anway, after a Good Night's sleep I worked out how I should have done it: $regexp = <STDIN>probably with a chomp somewhere, and then $line =~ m?$regexp?That seems to work fine, so thanks to all who replied. Additional remark on May 20thactually, that didn't work. Due to the special peculiarities of m?xxxxx? matches, you need to call reset whenever you change $regexp. Much simpler just to use a different delimiter, so here is my final versions, now working as intended: $line =~ m#$regexp#
In Section
Seekers of Perl Wisdom
|
|