Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Returning a hash and looping on the results.

by Anonymous Monk
on Apr 18, 2014 at 15:22 UTC ( [id://1082781]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Returning a hash and looping on the results.
in thread Returning a hash and looping on the results.

OK, this I found to be the better way of doing it:

my $result = data(); foreach my $res (@$result) { my $name = $res->{'username'}; my $city = $res->{'city'}; print "User Name = $name - City: $city\n"; } my @all_data = (); sub data { ... db code stuff ... my %no_name_found; if(@$sql) { for(my $i = 0; $i < @$sql; $i++) { my $user_name = $sql->[$i]{'username'} || ''; my $city = $sql->[$i]{'city'} || ''; # verify user name, this name will come back from this sub check_ +name my $no_name = check_name ( user => $user_name, ); #Get a new hash for the data my %data; $data{username} = $user_name; $data{city} = $city; push @all_data, \%data; } } return \@all_data; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-18 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found