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

Re: Avoiding vivification with array slice

by moritz (Cardinal)
on Sep 09, 2008 at 12:45 UTC ( [id://710069]=note: print w/replies, xml ) Need Help??


in reply to Avoiding vivification with array slice

Does anyone have a nice, concise syntax for looping over "the first N elements of an array, without vivification"?
use List::Util qw(min); for my $value (@a[0 ... min($#a, $N)]) { }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-23 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found