in reply to Re^4: DBI hashref does not return data in order of query
in thread DBI hashref does not return data in order of query
I've used this quite a bit in code where I'm reading in files which don't have the column names in them as a header. This should get you a hash per record which sounds like what you want.my @cols = ('field1','field2','field3'); while ( my $row = $sth->fetchrow_arrayref ) { # create a hash ref to assign values to cols my $tmp = {}; @$tmp{@cols} = @$row; push @xml_array, $tmp; } # Access fields like so... print $xml_array[0]->{field1},"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: DBI hashref does not return data in order of query
by hallikpapa (Scribe) on Oct 23, 2007 at 17:18 UTC |