Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Problem with doubles results

by frank1 (Scribe)
on May 17, 2024 at 17:47 UTC ( [id://11159510]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Problem with doubles results
by Corion (Patriarch) on May 17, 2024 at 17:51 UTC

    Please post the actual code together with its actual output. The code you posted cannot produce the output you show:

    SELECT name country gender FROM tbl_U WHERE location = ?

    This is not valid SQL.

    { "info": "\t\t\t\t\t\t \n<p>John UK Male</p> \n<p>Kieth UK Male</p>" ...

    This output cannot be produced by

    $json_msg .= <<HTML; <p>$name $country $gender</p> HTML

    ... as this line does not contain any tabs.

    You may want to learn about scoping and where to put your variable declarations. Or at least think about why you are appending to $json_msg, instead of simply setting it to the desired value.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Problem with doubles results
by NERDVANA (Curate) on May 17, 2024 at 20:36 UTC
    You declared my %hash outside of the loop, so each time you push @updated_data, \%hash you get a reference to the same hash. So, it will be an array of many references to the final value of the hash on the last loop iteration.

    Declare my %hash inside the loop to get a new one each time.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-06-24 19:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.