mstevens said:

> Why does:
> 
> #!/usr/local/bin/perl -w
> 
> use strict;
> use warnings;
> 
> my $a = "wibble mmnipm";
> 
> if ($a =~ mmnipm) {
>  print "match\n";
> } else {
>  print "no match\n";
> }
> 
> do what it does, and give no warnings?

>From perlop (section on binding operators):

"If the right argument is an expression rather than a search pattern,
substitution, or transliteration, it is interpreted as a search pattern at
run time. This can be less efficient than an explicit search, because the
pattern must be compiled every time the expression is evaluated."

Which explains why it's converted to /mmnipm/, but not why you don't get a
bareword warning.

Then muttley added:

> Because it's exactly the same as doing m!nip! - you've just used 'm' as
> the delimiter character.
> 
> it's matched on the 'nip' not the mmnipm. 

Not true actually. If you want to use a letter as a regex delimiter (and you
_shouldn't_) you need to put a space between the the 'm' (or 's' or 'tr')
and the first delimiter.

Which is why Adrian's

m mnipm

worked without error.

The only mystery here is why the "bareword" error seems to have been removed
somewhere between 5.005_02 and 5.6.x (which I assume mstevens is using -
from the "use warnings").

Dave...

-- 


The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged. If the reader 
of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  
If you have received this communication in error, please 
re-send this communication to the sender and delete the 
original message or any copy of it from your computer
system.

Reply via email to