Compilers-R-Us has asked for the wisdom of the Perl Monks concerning the following question:
I have a question related to "Calling a method within a double-quoted string" - I would like to call a method within regex match expression, like
I can almost do it with 5.005+ as in:print "Matched!" if $myvar =~ /\Q$myob->print\E/;
However, I have to pre-escape the return result. Of course I can use a temporary variable, but that damages the readability. Unfortunately, I am stuck at 5.004 compatibility and (?{...}) is not supported. Also, I feel that it is my birthright to do this in one line. Is there a one-liner to do this? Also, is there a reason that the binding is not stronger for '->'?print "Matched!" if $myvar =~ /(?{$myob->escaped})/;
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I call a method within a regular expression (5.004)?
by tedv (Pilgrim) on Nov 02, 2000 at 00:28 UTC | |
Re: How do I call a method within a regular expression (5.004)?
by Compilers-R-Us (Initiate) on Nov 02, 2000 at 01:50 UTC |
Back to
Seekers of Perl Wisdom