in reply to my $x or my ($x)
This has just caught me out in a while loop for getting information from a database
my $query = $dbh->prepare("SELECT idFrame, name, colour FROM F +rame"); $query->execute(); while (my ($frame) = $query->fetchrow_hashref) { push @frames, $frame; }
This loop never ends!
Although $query->fetchrow_hashref returns undef once all the rows have been returned, the condition as whole doesn't so the loop continues...
This is what I really wanted (and how have)
my $query = $dbh->prepare("SELECT idFrame, name, colour FROM F +rame"); $query->execute(); while (my $frame = $query->fetchrow_hashref) { push @frames, $frame; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: my $x or my ($x)
by LanX (Saint) on Jan 02, 2021 at 23:41 UTC | |
by Bod (Parson) on Jan 03, 2021 at 12:56 UTC |