my @users; foreach my $id (@userIds) { push (@users,User->new($id)); } #### my @users=User->new($id1,$id2,$id3,$id4); #### sub new { my $proto = shift(@_); my $userId=shift(@_); my $class = ref($proto) || $proto; my $self = { "user_id"=> undef, "user_name" => undef }; bless ($self, $class); my $href = GETSQL("SELECT user_name FROM users WHERE user_id = $userId"); @{$self}{keys %{$href}} = values %{$href}; return $self;