The regular expression // works differently in split then elsewhere...
I think I'd consider this just another special-case fixup prior to running split rather than a true difference in the function of m//:
This is probably just a matter of emphasis and interpretation.c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $x = qq{1234 abcd 5678}; dd split //, $x; dd split /\b|\B/, $x; " (1 .. 4, " ", "a" .. "d", " ", 5 .. 8) (1 .. 4, " ", "a" .. "d", " ", 5 .. 8)
... line anchors /^/ and /$/ don't require the /m option to match lines in a string.
Checking the docs, I recalled seeing this discussed before, but it's another one of those very specialized special cases that evaporates from my memory with time. However, it's not true for the /$/ case (per the docs (or at any rate, the docs say nothing about special-casing it)):
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $x = qq{1234 \n abcd \n 5678}; dd split /^/, $x; dd split /$/, $x; " ("1234 \n", " abcd \n", " 5678") "1234 \n abcd \n 5678"
Give a man a fish: <%-{-{-{-<
In reply to Re^4: Why split function treats single quotes literals as regex, instead of a special case?
by AnomalousMonk
in thread Why split function treats single quotes literals as regex, instead of a special case?
by likbez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |