Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: But I want null values in my array

by AnomalousMonk (Bishop)
on Mar 11, 2020 at 20:45 UTC ( #11114148=note: print w/replies, xml ) Need Help??


in reply to But I want null values in my array

I agree that Text::CSV is almost certainly the best way, but here's a reinvented wheel (note the leading "null" field introduced into the example):

c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $s = ',1,,3,4,,,'; ;; my @ra = map { m{ \A \s* \z }xms ? undef : $_ } split ',', $s, -1; dd \@ra; " [undef, 1, undef, 3, 4, undef, undef, undef]


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2020-05-29 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (171 votes). Check out past polls.

    Notices?