http://www.perlmonks.org?node_id=412310


in reply to Naked quotes work like m//?

I too have noted that 'bug' as well which as you note turns out not to be one. It is possibly a documentation bug. Probably like me you remembered reading If ``/'' is the delimiter then the initial m is optional in perlre and then made the assumption (IMHO justified) that this implicitly indicates that:

If ``/'' is NOT the delimiter then the initial m is NOT optional.

This of course is an implicit assumption. perlre does not define the behaviour when the delimiter is not a / and the m is missing. As you note the m is optional with a (small) range of other delimiters. This dates back to Perl 5.6.0 and perhaps earlier.

There are actually only a limited number of delimiters that will work in this /* m free, non /* context. Essentially any perl expression that will evaluate as a stringy thing and is a valid RVALUE can be used:

$a = "2foobar\n"; print $a if $a =~ m"foo"; print $a if $a =~ eval{"bar"}; print $a if $a =~ q!foo!; print $a if $a =~ (6*7-40); # yes this evaluates to 2, gets stringif +ied and matches

Practically speaking that means " and ' with most of the other commonly used non / regex delims like ! , | {} all creating syntax errors or not matching.

cheers

tachyon