I wanted to split a string on | characters today and ran into a little bother. My first attempt looked like this:
split "|", $strwhich did not do what I expected so I tried:
split "\|", $str;which produced exactly the same result! My last attempt was:
split "\\|", $str;which generated the result I was after. What is going on here? The perlfunc entry for split doesn't seem to help much.
use warnings; use strict; my $str = "lhs|rhs"; print join " ", split "|", $str; print "\n" . join " ", split "\|", $str; print "\n" . join " ", split "\\|", $str; prints: l h s | r h s l h s | r h s lhs rhs
In reply to Surprised by split by GrandFather
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |