in reply to Matching dot using regexp

I am trying to match the dot using the following regular expression

please meditate on the meaning of the words "regular expression" (its not "string literal")

Replies are listed 'Best First'.
Re^2: Matching dot using regexp
by AnomalousMonk (Archbishop) on Oct 10, 2017 at 08:43 UTC

    <pedantic>
    The regular expression that follows in the OP is  /./ in the split expression. And FWIW, it could, indeed, be a string literal:

    c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $tim = '01:00:01.004'; ;; $tim =~ s/:/./g; print qq{new time is '$tim'}; my @outputlist = split '\.', $tim; dd \@outputlist; " new time is '01.00.01.004' ["01", "00", "01", "004"]
    </pedantic>


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

      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!

        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.

        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:  <%-{-{-{-<

      Heh slow days and i draws the ijits. Regular expressions are not english or chinese they're regex. No matter qr// or qr'' or qr"" whats inside is a different language it aint a plain string