Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by Tux (Monsignor)
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


Comment on Re: Split and join - semicolons around empty fields are lost
Select or Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (19)
As of 2015-07-29 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls