in reply to Weirdness when reading from DBM file
use DBM::Deep; my $dbh = get_dbh(); # This is the magic. :-) my $db = DBM::Deep->new( 'db_file.db' ); my @keys = qw(employee_id firstname lastname title dept salary date_hired); my @values = @{$dbh->selectall_arrayref($query)}; for my $v (@values){ my @vals = @$v; # one ID per array for (@vals){ $_ = '-' unless $_; # in case of empty fields } # Map is a wonderful piece of magic. Look really really hard at # this code before freaking out. $db->{$vals[0]} = { (map { $keys[$_] => $vals[$_]; } 0 .. $#keys) }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Weirdness when reading from DBM file
by mojodaddy (Pilgrim) on Sep 12, 2007 at 01:08 UTC | |
by dragonchild (Archbishop) on Sep 12, 2007 at 13:27 UTC | |
|
Re^2: Weirdness when reading from DBM file
by mojodaddy (Pilgrim) on Sep 12, 2007 at 00:24 UTC |