Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: [Solved] Avoiding repeated undefs

by talexb (Chancellor)
on Feb 27, 2019 at 00:40 UTC ( [id://1230599]=note: print w/replies, xml ) Need Help??


in reply to [Solved] Avoiding repeated undefs

It sounds like you already have a good solution, but for me, the obvious one is to pop the output from split into an array, then take the first and last values.

my @array = split(/\s+/, $_); my ( $key, $value ) = @array[ 0, -1 ];
That approach doesn't care if the number of values changes -- you always get the first and the last values. Also, the split could be simplified to just
my @array = split(/\s+/);
because $_ is the default parameter for this function.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-20 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found