in reply to Re^3: Ordering Template cards
in thread Ordering Template cards

> while (my $card = $cards->fetchrow_arrayref), since that's a scalar assignment and it'll return undef (false).

Well it could have been designed to detect that it's called in list context and return an empty list when the table is exhausted.

Or at least throw an error.

But I have a strong deja-vu feeling right now, I think I said this before...

DBI.pm is one of the messier parts of Perl's eco system.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: Ordering Template cards
by haukex (Archbishop) on Jan 26, 2021 at 12:36 UTC
    Well it could have been designed to detect that it's called in list context and return an empty list when the table is exhausted.

    There are arguments to be made for and against this. If a method is documented to return a scalar, then you'd expect to be able to do my %data = ( foo => $sth->fetchrow_arrayref, bar => 123 );, if it suddenly returns the empty list that'd be a problem.

      haukex++ That's a very good point!

      But IMHO the culprit here is the design of the fat comma => as pairing operator.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery