in reply to DBI help, aka confused newbie
foreach $i ($$array_ref) {
That should be @$array_ref.
if($Sort == "byname") {
== should be eq.
$DB{ $$i[0] } = [ $$i[1],$$i[2],$$i[3] ];
Good enough, but consider using arrow notation instead: $i->[0].
Anyway, the same using DBIx::Simple would be:
Or, if you want hashes (easier to use, but not as efficient) and have a $sortby that is 'name' or 'date' (instead of a $sort that is 'byname' or 'bydate'), you can just use:%DB = $db -> query('SELECT name, height, width, date FROM mydatabase') -> map_arrays( { byname => 0, bydate => 3 }->{$sort} );
%DB = $db -> query('SELECT name, height, width, date FROM mydatabase') -> map_arrays($sortby);
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|