Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: [Solved] Avoiding repeated undefs

by talexb (Canon)
on Feb 27, 2019 at 00:40 UTC ( #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
Node Status?
node history
Node Type: note [id://1230599]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2019-07-20 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?