Keep It Simple, Stupid | |
PerlMonks |
Regex without 'm' or '/'by dvergin (Monsignor) |
on Jul 10, 2002 at 01:30 UTC ( [id://180659]=note: print w/replies, xml ) | Need Help?? |
The example that BorgCopyeditor supplies with his question brings up an interesting point. Why does this work:
if($query=~$term) {...}
Or, to offer a very plain example, why does this work:
The rule I learned was (quoting from perlop): "If "/" is the delimiter then the initial m is optional." Fair enough. The implication is: But it is not so. As I said above, both of the examples at the top of this response work. Why? What I cannot find in the on-line docs (update: see danger's response below) but I know from experimentation and the words of Camel 3, page 144, is that, even without the 'm' or the '/', the righthand side of =~ "still counts as a m// matching operation, but there'll be no place to put any trailing modifiers, and you'll have to handle your own quoting." So... The present writer is not responsible for any sideways looks any of these may earn you from your peers.
------------------------------------------------------------
In Section
Seekers of Perl Wisdom
|
|