> my $success = $sth->execute($sk);
> > my ($user, $session) = $sth->fetchrow_array  || &error('SQL',
$sth->errstr);
>                                               ^^^^
>
> > == end snip ==
> >
> > In that way only the scalar $user was set and contained the value of
> > "session" from the database.
>
> The || operator puts the call to $sth->fetchrow_array in a scalar context,
> so it returns only one of the values selected.  Replace the || with or,
which
> has lower precedence, and it should work as you expected.
>
>
> However, if $sth->fetchrow_array() really returned the session value, not
> the user value, that is a bug, because in a scalar context
fetchrow_array()
> should return the value of the first selected field, not the last.  I
don't
> see this bug in the latest version of DBI, though.
>
You have point there, tho you might also expect that in 'real' scalar
context $user would contain the value 2, which is the length of the list.
But in general it is not a good idea to use || or 'OR' in a list or hash
assignment.

Maarten

Reply via email to