in reply to Re^2: Matching dot using regexp
in thread Matching dot using regexp

If it was a string literal why do you need to escape the dot?

I read thru split couldn't find a a mention of strings as separators.

From my knowledge using a delimiter in single quotes is still a regex, albeit without variable interpolation like in double quotes.

UPDATE

After reading the dialog it seems that what you meant, a literal string without interpolation used as regex.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^4: Matching dot using regexp
by soonix (Chancellor) on Oct 10, 2017 at 10:19 UTC
    Somewhere in the middle of that doc it says that PATTERN can be
    a string composed of a single space character (such as ' ' or "\x20" , but not e.g. / / ).
    However, the only PATTERN strings that I find there are whitespace (PATTERN defaults to " " if omitted) and the empty string.

      split is happy with any string (or anything that can be converted to a string) as a /PATTERN/, e.g.,

      c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $tim = '10:00:10.004'; ;; my @outputlist = split '[:.]', $tim; dd \@outputlist; ;; my $p = 10; @outputlist = split $p, $tim; dd \@outputlist; " [10, "00", 10, "004"] ["", ":00:", ".004"]
      However, I would incline to use  // qr// m// for any but the most simple and straightforward patterns; I vaguely recall pitfalls involving backslashes.


      Give a man a fish:  <%-{-{-{-<

Re^4: Matching dot using regexp
by AnomalousMonk (Archbishop) on Oct 10, 2017 at 10:15 UTC

    Well... I don't quite understand the point you're making, but...

    If it was a string literal why do you need to escape the dot? ... strings as separators.
    In my understanding, a string (or anything that's not a  Regexp object) supplied as a  /PATTERN/ to split will be compiled to a regex, so a single- or double-quoted dot has meta-nature and must be meta-escaped to match only a period.


    Give a man a fish:  <%-{-{-{-<