in reply to Surprised by split
I think split behaves differently if the first parameter is a normal string instead of a regex. The perlfunc documentation doesn't mention this and I can't remember how exactly it differs. Anyway since | is a regex special character (alternation) you need to escape it. I'd normally write this as:
split /\|/, $strThe reason you need two \s is because of the behaviour of double quotes - just try:
print "|"; print "\|"; print "\\|";
and you should see what's happening.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Surprised by split
by extremely (Priest) on Aug 11, 2005 at 14:09 UTC |