in reply to double quote vs single quote oddities. I need enlightenment

The most important point is that split interprets the first argument as a regex. So split '.', split "." and split /./ are exactly the same.

The rest of your question is easy to answer if you just print out the string or regex that split sees:

$ perl -wle 'print "\."' . # so it's the same as /./ $ perl -wle 'print "\\."' \. # as a regex, matches a literal dot

In the case of regexes, /\./ matches a literal dot, /\\./ a backslash followed by any character, /\\\./ a backslash followed by a literal dot and so on.

Update: There's also a special quoting for to create regexes, that avoids having to use excessive amounts of backslashes if you want to store a pattern in a variable:

my $regex = qr{\.}; # matches a literal dot my @chunks = split $regex, 'dot.delimited.string';
Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^2: double quote vs single quote oddities. I need enlightenment
by lyapunov (Novice) on Jul 08, 2010 at 17:28 UTC

    Moritz, thank you for the reply and the use of the qr. I just read the "Staying in Control" of Chapter 5.

    Thanks! That is a big help.