CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Array in objs

 



maclarensg
New User

Sep 5, 2008, 3:24 AM

Post #1 of 2 (3035 views)
Array in objs Can't Post

# Send the request to the server and retrieve the response.
my $resp = $chan->send($request);

foreach my $client ($resp->{list}){
print $client->{$name};
}
---------------------------------------------------------
my above code, $resp->{list} is an array.
But why can't I use a foreach.

below is the error I've got

[dcs@dcs ~]$ sudo ./listallclients.pl
Global symbol "@client" requires explicit package name at ./listallclients.pl line 23.
Global symbol "$name" requires explicit package name at ./listallclients.pl line 23.
Execution of ./listallclients.pl aborted due to compilation errors.


KevinR
Veteran


Sep 5, 2008, 12:45 PM

Post #2 of 2 (3027 views)
Re: [maclarensg] Array in objs [In reply to] Can't Post

If you are sure it is an array:


Code
foreach my $client (@{$resp->{list}}){ 
print "$client\n";
}


See what the value of $client is in order to proceed from there.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives