Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: MySQL to Hash Revised.

by poj (Priest)
on May 18, 2012 at 20:26 UTC ( #971364=note: print w/ replies, xml ) Need Help??


in reply to MySQL to Hash Revised.

I'm trying to do what the first program does but by populating the hash from the database

I that case maybe you should be using the Name field as the key to your hash like this

$sql = "select * from scanner.vulnerabilities"; $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; my %ref; while (my $row = $sth ->fetchrow_hashref() ){ $ref{ $row ->{'Name'} }{'port'} = [ $row ->{'port'} ]; }

Also, this code only needs to run once so you can move it up outside the while loop.

poj


Comment on Re: MySQL to Hash Revised.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-12-21 18:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls