Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

OOP: How to construct multiple instances of a class at once

by DrGTO (Initiate)
on Nov 14, 2012 at 15:50 UTC ( #1003841=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    my @users;
    foreach my $id (@userIds) {
           push (@users,User->new($id));
  2. or download this
    my @users=User->new($id1,$id2,$id3,$id4);
  3. or download this
    sub new {
        my $proto = shift(@_);
        my $href = GETSQL("SELECT user_name FROM users WHERE user_id = $us
        @{$self}{keys %{$href}} = values %{$href};
            return $self;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1003841]
Approved by marto
Front-paged by Tanktalus
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-12-01 08:55 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (797 votes), past polls