mhearse has asked for the wisdom of the Perl Monks concerning the following question:
I thought I would do this by assigning the array ref to a scalar on the first iteration. But instead of the first iteration, I end up with the last. (If there are ten rows that matched, $first contains the results from row 10... rather than row 1). How can a copy of the first array ref be saved for later use. Thanks.my $sth = $dbh->prepare("SELECT * FROM tickets ORDER BY ticket_id"); $sth->execute(); my $first; my $i = 0; while (my $record = $sth->fetch()) { if ($i == 0) { $first = $record; } blahh... blahh... $i++ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Saving array reference
by moot (Chaplain) on Apr 30, 2005 at 19:59 UTC | |
by jZed (Prior) on Apr 30, 2005 at 20:28 UTC | |
by Errto (Vicar) on May 01, 2005 at 01:34 UTC | |
by mhearse (Chaplain) on Apr 30, 2005 at 20:18 UTC | |
|
Re: Saving array reference
by jZed (Prior) on Apr 30, 2005 at 20:26 UTC |