Just another Perl shrine | |
PerlMonks |
Re: Tutorial suggestion: split and joinby gmax (Abbot) |
on Aug 28, 2003 at 22:54 UTC ( [id://287545]=note: print w/replies, xml ) | Need Help?? |
It is not only the intermediate elements. The effect of a delimiter are felt on the empty elements at the beginning and the end of the source string. Consider the following examples
The best choice if you want to split a string by spaces and you don't want the empty elements is to use a simple quoted space (not a regex) as a delimiter, as the last example shows. From perldoc -f split
Update If you want to document the above behavior, you can use B::Deparse.
However, this will work in Perl 5.8.0 but not in 5.6.1. (in 5.6.1 the output of the one-liner is correct, but the deparsed code is not). Apparently, there was a bug that was recently fixed. Thanks to diotalevi for his useful analysis in this matter. _ _ _ _ (_|| | |(_|>< _|
In Section
Meditations
|
|