I'm trying to use a hash and I'm not sure what I'm doing wrong. I believe I'm either populating my has wrong, or printing it wrong. Can someone help point out what my problem (with the code) is?
undef %db_processes;
$dbh = DBI->connect("dbi:ODBC:$dsn_name", "$dsn_user", "$dsn_pwd")
or quittext_opc ("Failed to connect to database $dsn_name\n",
+$app, $SEV1, $GRP3, "5051", $STAT1);
$qry = "select sid,'|',serial#,'|',status,'|',process,'|',username,'|'
+ from v\$session;";
$sth = $dbh->prepare($qry);
$sth->execute();
while ( @dummyrow = $sth->fetchrow_array )
{
($pp0,$pp1) = split /:/,$dummyrow[6];
$db_processes{$pp1} = {SID => $dummyrow[0],
SERIAL => $dummyrow[2],
STATUS => $dummyrow[4],
PROCESS => $dummyrow[6],
USERNAME => $dummyrow[8],
};
}
foreach $hashy (@db_processes)
{
print "in if\n";
print "$hashy->[0]\n";
}
$dbh->disconnect();
The data is extracted from the database fine. I have printed the $dummyrows and see the data. I just can't get the hash to print values.
Thanks, Jim
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.