in reply to MySQL results inserted into Perl variable
The following should give you a reference to an array of hashref in $ref:
Each hashref should have 'field1' and 'field2' as keys. You can pass that around as needed and wind up with something like this:my $ref = $dbh->selectall_arrayref( "SELECT field1, field2 FROM location WHERE restriction = 'RESTRICTION NAME'", { Slice => {} } );
BTW, you left out use strict; and use warnings; only for the sake of brevity, right?for my $row_ref ( @{$ref} ) { # do something awesome with $row_ref->{field1} and $row_ref->{fiel +d2}. }
Update: edited SQL for better formatting
|
|---|