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

Re: MySQL to Hash Revised.

by poj (Prior)
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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971364]
[M4ver1k]: I feel like being able to toggle a running script on the fly by updating variables from a config file using Config::Simple. But in the while loop, it seems like it doesn't update the variable after the first past. Is this generally just a bad idea?
[M4ver1k]: pass*

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-11-20 03:04 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (283 votes). Check out past polls.