Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Perl: Split/format the output and append it to an array

by einhverfr (Friar)
on Sep 15, 2014 at 04:45 UTC ( [id://1100553]=note: print w/replies, xml ) Need Help??


in reply to Re: Perl: Split/format the output and append it to an array
in thread Perl: Split/format the output and append it to an array

In the interest of balancing clarity and robustness with map, I would suggest the following as an example.

map { /xlink (.+?) /; $1 ? $1 : (); } @xlinks

Of course the trinary operator here is not needed. However, oen problem I have seen with map is accidently clobbering the return values if I am not careful. Therefore if I have a conditional in the return, I try to use a trinary operator at the very end.

BTW, I don't mind putting significant code in a map block. However one does have to be careful about it. I think if the code gets too much, one is better off usually putting the code in a function and calling that rather than going with a for loop.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 13:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found