[pm-h] Discussion about delimiters for m//
G. Wade Johnson
gwadej at anomaly.org
Fri Feb 14 15:55:16 PST 2014
Near the end of the meeting last night, there was a minor discussion at
the whiteboard about which characters Perl allows as delimiters on the
match operator.
According to PerlDoc:
If "/" is the delimiter then the initial "m" is optional. With the
"m" you can use any pair of non- whitespace (ASCII) characters as
delimiters. This is particularly useful for matching path names that
contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is the
delimiter, then a match-only- once rule applies, described in
"m?PATTERN?" below. If "'" is the delimiter, no interpolation is
performed on the PATTERN. When using a character valid in an
identifier, whitespace is required after the "m".
So, that means that
$str =~ m mabc+m;
is valid Perl and it matches "abc+".
Weird. I can't think of a real use for it and using it in production
code is likely to get you beaten by whoever maintains your code.
G. Wade
--
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not 'Eureka!' (I found it!) but 'That's funny ...'
-- Isaac Asimov
More information about the Houston
mailing list