Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Pushing Arrays

by xdg (Monsignor)
on Aug 15, 2005 at 13:00 UTC ( [id://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 }

-xdg

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

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

    Tom

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-07-22 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.