http://qs321.pair.com?node_id=11114141


in reply to But I want null values in my array

You need to give split an explicit special limit of -1 something negative if you want trailing empty fields to be returned. The relevant bit of the doc is below:

If LIMIT is omitted (or, equivalently, zero), then it i +s usually treated as if it were instead negative but with + the exception that trailing empty fields are stripped (empt +y leading fields are always preserved); if all fields are + empty, then all fields are considered to be trailing (and are +thus stripped in this case). Thus, the following: print join(':', split(',', 'a,b,c,,,')), "\n"; produces the output 'a:b:c', but the following: print join(':', split(',', 'a,b,c,,,', -1)), "\n"; produces the output 'a:b:c:::'.

Edit: tweaked wording.

The cake is a lie.
The cake is a lie.
The cake is a lie.