in reply to How to differentiate an empty array from an unitialized one?

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:  <%-{-{-{-<