Thank you all for your responses -- they're much more than I expected.
Since this reply seemed to have the most solid ways for checking that my fetchrow_hashref() call was working, I tried the suggestions therein. Sadly, I found that I was getting a valid hashref returned, as:
print "Errors are: $sth->err\n";
print "I got out: ref($rec_ref)\n";
Gives me:
Errors are: DBI::st=HASH(0xe2478)->err
I got out: ref(HASH(0xf9d14))
both of which seem to indicate that I do, indeed, have a valid hashref to work with.
To expand on what's going wrong, let me pull out the following bit of code from my program:
if ($rec_ref->{'company'} ne "")
{
%ref = %$rec_ref;
$found = 1;
}
$dbh->disconnect();
if ($found) {
return %rec;
}
else {
return undef;
}
I know from the database that there will *always* be a company value returned; thus, I was using that as a sanity-check that my hashref was good. From there, I set a flag on how to return from the subroutine I'm in; if it's good, I return the hash that should be filled by dereference from my hashref, otherwise undef.
What's actuall happening here is that I *am* getting a value for $rec_ref->{'company'} (I've checked that with a print statement), and I know I'm returning a hash -- but the subroutine which uses that hash is acting as if it's empty. That subroutine is known good from other activities within my script, so I won't paste it here.
Further comment upon this expanded code would be greatly appreciated. Again, thanks for all of your help.
Alex Kirk
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.