in reply to Surprised by split
My last attempt was: split "\\|", $str; which generated the result I was after.
This is known as the "lisp syntax" for regular expressions. The reason it's called that is because in lisp, there is no dedicated quoting mechanism for regular expressions, and so they have to be given in code as quoted strings. Any lisp manual will explain why the double-backslashing of everything is necessary.
Perl does provide dedicated quoting constructs for regular expressions, and your regular expressions will be much easier to read and maintain if you use them, rather than giving your regular expressions in lisp syntax using regular double-quoted strings.
|
|---|