in reply to push/append to hash in a loop

I think you want:

$hasho{ $result[0] } = $result[1];

You could also get DBI to do the work for you. Replace your loop with:

my %hasho = %{ $sth->fetchall_hashref( 'org_id' ) };

This will produce something a little different than you're expecting, though. Each entry in %hasho will be a hashref with two keys ('org_id' and 'org_name').

If you're willing to go that route, you can replace the prepare and execute with:

my %hasho = %{ $dbh->selectall_hashref( $sql, 'org_id' ) };

Replies are listed 'Best First'.
Re^2: push/append to hash in a loop
by djbryson (Beadle) on Mar 20, 2007 at 21:09 UTC
    thank you