Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Preserving empty fields in split

by pjf (Curate)
on Feb 05, 2004 at 12:11 UTC ( #326749=note: print w/ replies, xml ) Need Help??


in reply to Working of split

G'day Hena,

If you don't want split to remove trailing empty fields, then you can supply it with a third argument, set to a negative value. Normally this is the maximum number of fields you wish split to generate, but Perl will interpret a negative number to mean leaving all fields intact, including empty ones.

In your particular example, you would change your split line to:

my @a = split(/\t/,$a,-1);

For more information on this feature, check out perldoc -f split or the online documentation on this function.

All the very best,


Comment on Preserving empty fields in split
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://326749]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-04-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls