Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Split and join - semicolons around empty fields are lost

by Tux (Abbot)
on Sep 06, 2011 at 07:56 UTC ( #924329=note: print w/replies, xml ) Need Help??


in reply to Split and join - semicolons around empty fields are lost

That is the correct and documented behavior (perldoc -f split). Trailing empty fields are dropped on split when you use it like that. If you want to keep them, use:

my @row = split m/;/ => $_, -1;

As corion said, safer to use Text::CSV_XS.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Split and join - semicolons around empty fields are lost
by james2vegas (Chaplain) on Sep 06, 2011 at 09:06 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924329]
help
Chatterbox?
[marto]: it probably exists in one of the PPM repositories
[marto]: failing that see the README
[mark4]: I installed "PAR" from the ppm install window. pp.exe. did not show up.
[marto]: it should just be a script, pp, or on windows pp.bat, post install you should just be able to call pp -x packed.exe source.pl as the PPM package should put everything required into the appropriate path
[marto]: ah, some time ago pp became it's own package, try searching your repo for PAR::Packer
[marto]: again, Strawberry + cpanm for the win: cpanm pp to install

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-01-19 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (218 votes). Check out past polls.

    Notices?