in reply to Re: Temp variable performace vs Inline behavior
in thread Temp variable performace vs Inline behavior
BrowserUk’s solution:
my @devices = grep{ defined( $_ = parse_node( $_ ) ) } @nodes;
is compact and efficient, but has one side-effect: the assignment to $_ clobbers the contents of @nodes.
In cases where this is undesirable, the following seems to do the same without the side-effect:
my @devices = grep { defined } map { parse_node( $_ ) } @nodes;
Or is there a simpler way?
Athanasius <°(((>< contra mundum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Temp variable performace vs Inline behavior
by tobyink (Canon) on Jun 27, 2012 at 16:44 UTC |