Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: Avoiding vivification with array slice

by ikegami (Pope)
on Sep 09, 2008 at 19:45 UTC ( #710184=note: print w/replies, xml ) Need Help??

in reply to Re^2: Avoiding vivification with array slice
in thread Avoiding vivification with array slice

The point of the defined wasn't to prevent autovivification, but to implement the grep you had in your original code. The following two snippets are equivalent.
@b = map { defined($a[$_]) ? ($a[$_]) : () } 0..5;
@b = grep { defined } map { $a[$_] } 0..5;

What you suggested (@b = map { $a[$_] } 0..5;) is *not* equivalent.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://710184]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2017-03-28 08:01 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (327 votes). Check out past polls.