Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

fetchrow_hashref Confusion

by Angel (Friar)
on Jun 15, 2002 at 17:39 UTC ( [id://174853]=perlquestion: print w/replies, xml ) Need Help??

Angel has asked for the wisdom of the Perl Monks concerning the following question:

How to I get at the hash it's self and not the reference? I need the hash that it returns to get at the data for a mail merge project?

Replies are listed 'Best First'.
(jeffa) Re: fetchrow_hashref Confusion
by jeffa (Bishop) on Jun 15, 2002 at 18:05 UTC
    By de-referencing:
    my %hash = %{$sth->fetchrow_hashref()};
    But you don't have to do that ... you could do something like:
    while (my $row = $sth->fetchrow_hashref()) { my $mail = $row->{mail}; print "$mail\n"; }
    just as easily IMHO.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: fetchrow_hashref Confusion
by runrig (Abbot) on Jun 15, 2002 at 18:18 UTC
    How to I get at the hash it's self and not the reference?

    The same way you work with any other hash ref:

    %hash = %$hashref; # or to get at a specific value: $value = $hashref->{key}; # or you can use fetchrow_arrayref: my @names = @{$sth->{NAME_lc}}; my %hash; while (my $values = $sth->fetchrow_arrayref) { @hash{@names} = @$values; }
Re: fetchrow_hashref Confusion
by VSarkiss (Monsignor) on Jun 16, 2002 at 00:09 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2025-07-08 06:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.