Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Pushing Arrays

by xdg (Monsignor)
on Aug 15, 2005 at 13:00 UTC ( #483836=note: print w/replies, xml ) Need Help??

in reply to Pushing Arrays

Be careful what you mean here and whether you want an array :

my @setargs = ( $set1, $set2 );

or a reference to an array:

my $setargs_ref = [ $set1, $set2 ];

You can push onto either, as long as you refer to it properly

foreach my $set (whatever loop) { push @setargs, $set; push @{ $setargs_ref }, $set; # explicit dereference }


Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^2: Pushing Arrays
by Roy Johnson (Monsignor) on Aug 15, 2005 at 13:57 UTC
    Of course, for situations like that, you don't actually need a loop. You can just
    push @setargs, whatever loop
    where whatever loop isn't a loop, but is the list (or array) being iterated over in the original code.

    Caution: Contents may have been coded under pressure.
Re^2: Pushing Arrays
by webchalkboard (Scribe) on Aug 15, 2005 at 14:41 UTC

    Thanks I was meaning a reference to an array, so that code helps a lot thanks,


    Learning without thought is labor lost; thought without learning is perilous. - Confucius | For the love of art...

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-04-01 05:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found