in reply to Re: scalar ref losing it's value?
in thread scalar ref losing it's value?

You probably want to put the rest of the code in the loop body

I thought that at first, but then I figured his query returns at most one row. Using a loop to fetch one item is very misleading. He should probably have used

my $dbpass = $sth->fetch; ($UIDholder, $LNholder) = @{$dbpass}; ...
or
my $dbpass = $sth->fetch or die("Bad data. XXX not found\n"); $sth->fetch and die("Bad data. Multiple XXX in table YYY\n"); ($UIDholder, $LNholder) = @{$dbpass}; ...

Replies are listed 'Best First'.
Re^3: scalar ref losing it's value?
by bart (Canon) on May 05, 2006 at 07:36 UTC
    Even if so, I wonder what it's supposed to do if he gets more than one row. Now he just ignores every one except for the last. Yours will ignore everything but the first, I think.
      The second snippet checks to make sure one, and only one row is returned. It dies if not.
Re^3: scalar ref losing it's value?
by jck (Scribe) on May 05, 2006 at 14:12 UTC
    actually, i was only trying to get one row back, so thank you for the improved code on accomplishing that....i still get very disordered in my thinking about dealing with arrays...i was trying a few things, and i kept getting back the array ref, rather than the array itself.