Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Fooled By Splitby roho (Bishop) |
on Nov 24, 2003 at 11:59 UTC ( [id://309508]=perlquestion: print w/replies, xml ) | Need Help?? |
roho has asked for the wisdom of the Perl Monks concerning the following question:
I used split to parse a simple comma-delimited text string (i.e. no embedded commas, no quoted values, etc) into an array variable and the last values in the text string were all null. It is important for my process to maintain the null (or undefined) entries in the array, however it appears that split does not create array entries (even undef entries) for trailing null entries in the text string. This is not at all the behavior I expected from split and I can find no way to work around it, other than appending a throw-away character to the end of the text string prior to splitting it, which seems awfully kludgey. I tried adding a limit number equal to the total number of entries I expected (including the trailing null entries), but it had no effect. Can anyone shed some light on split's behavior and/or suggest a cleaner work around? Thanks in advance. Sample code follows ...
"Its not how hard you work, its how much you get done."
Back to
Seekers of Perl Wisdom
|
|