Thanks to all... yeah the code I posted was splitting on the wrong character (that was an error in the test case, not in the code I found the problem in). More importantly was the "By default, empty leading fields are preserved, and empty trailing ones are deleted" sentence that I've never noticed before ... I've dealt with records that had empty fields before without problems -- it never occursed to me that trailing blank fields would be treated differently.
Since I won't allways know how many total fields I should expect (I was planning on using the length of hte array returend by split) I can either count the pipes, or just put an extra bogus field on the end before splitting it, and then pop it off. ... not sure how i feel about that, seems a bit ... dirty.
In reply to Re: Re: split/map weirdness: empty strings vs undef
by hossman
in thread split/map weirdness: empty strings vs undef
by hossman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |