Further to tinita's post: Note that when all empty strings are captured, join is orthogonal with split:
c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(pp); ;; for my $str ('0,1,.5,0,1', '.5,,0,1,', ',,,,', '123', '',) { ;; my @ra = split ( ',' , $str, -1 ); my $spstr = join ',', @ra; printf qq{'$str' -> %s -> >$spstr< \n}, pp(\@ra); die qq{split/join not orthogonal: '$str' '$spstr'} unless $str eq $ +spstr; } " '0,1,.5,0,1' -> [0, 1, ".5", 0, 1] -> >0,1,.5,0,1< '.5,,0,1,' -> [".5", "", 0, 1, ""] -> >.5,,0,1,< ',,,,' -> ["", "", "", "", ""] -> >,,,,< '123' -> [123] -> >123< '' -> [] -> ><
Update: Added the die qq{ ... } unless $str eq $spstr; statement just to emphasize the point.
Give a man a fish: <%-{-{-{-<
In reply to Re: How to differentiate an empty array from an unitialized one?
by AnomalousMonk
in thread How to differentiate an empty array from an unitialized one?
by iatros
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |