ciao a tutti
ho una sub che crea un array di hash cosi:
richiamo la sub ma non riesco ad accedere ai valori:codice:sub getSources { my $query = "select id, url from sources"; my $sth = $db->prepare($query); $sth->execute; my @arr_sources = (); while (my $recset = $sth->fetchrow_hashref) { my $hash_sources; $hash_sources{id} = $recset->{id}; $hash_sources{url} = $recset->{url}; push(@arr_sources, \$hash_sources); } $sth->finish; $db->disconnect; return \@arr_sources; }
come posso fare ad accedere ai vari hash e stampare i valori?codice:my @arr_sources = &getSources(); foreach my $source (@arr_sources) { print $source->[0]; }
grazie 1000
![]()


Rispondi quotando