Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced?

by hippo (Bishop)
on May 05, 2022 at 17:22 UTC ( [id://11143600]=note: print w/replies, xml ) Need Help??


in reply to Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced?

Could I have written it better, cleaner, or safer?

Better and cleaner, yes. Your $data is an array of arrays and you convert it to an array of hashes by hand. Far better to have DBI do that for you.

return $dbHandle->fetchall_arrayref ({});

BTW, I would rename that variable. $db is your DB handle. What you have called $dbHandle is a statement handle. Anyone else coming to this code would be confused by that.


🦛

  • Comment on Re: Is there a cleaner way to write this code below, which includes derferencing references, that themselves have to be dereferenced?
  • Download Code

Log In?
Username:
Password:

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

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

    No recent polls found