Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Temp variable performace vs Inline behavior

by tobyink (Canon)
on Jun 27, 2012 at 16:44 UTC ( [id://978716]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Temp variable performance vs Inline behavior
in thread Temp variable performace vs Inline behavior

You could use the same technique but clobber a temporary array instead...

my @devices = grep { defined($_ = parse_node($_)) } my @tmp = @nodes;

Or you could use map:

my @devices = map { my $x; defined($x=parse_node($_)) ? $x : () } @nodes;

If parse_node was written to return the empty list in cases of failure (rather than returning the scalar undef), then it would just be:

my @devices = map { parse_node($_) } @nodes;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-28 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found