Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: loop thru 3-element array?

by kelan (Deacon)
on Sep 28, 2004 at 14:23 UTC ( #394598=note: print w/replies, xml ) Need Help??


in reply to Re: loop thru 3-element array?
in thread loop thru 3-element array?

Since you're making a separate copy of the list that gets passed in anyway, you could also use the splice trick that merlyn showed above, and get rid of all the arithmetic.

sub by_groups_of { my $by = shift; return sub { () } if ! $by || $by =~ /\D/ || ! @_; my @list = @_; # here's the copy. we're safe to splice return sub { splice @list, 0, $by }; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2022-09-28 23:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?