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 (Archbishop)
on Mar 11, 2020 at 20:45 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11114148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found