in reply to double quote vs single quote oddities. I need enlightenment
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';
|
|---|
| 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 |