in reply to Re: MySQL results inserted into Perl variable
in thread MySQL results inserted into Perl variable
The only change that I would make to the foregoing is that I would choose to specify the column-name, not as a bareword, but as a literal string, viz:
... $data->[0]{'field1'};
By far, the most common practice in any case is to let the row of data be returned as a hashref, then to retrieve the fields from it by column-name. If you feel cozy working with Perl variable-names from that point forward (and there’s certainly something to be said for that ...), that’s easily done. After retrieving the row as a hashref, do this:
my $field1 = $data->[0]{'field1'};
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: MySQL results inserted into Perl variable
by Athanasius (Archbishop) on Jul 09, 2014 at 04:37 UTC | |
|
Re^3: MySQL results inserted into Perl variable
by Anonymous Monk on Jul 09, 2014 at 01:29 UTC |