in reply to Reading data from Access into a Hash
By 'later use' do you mean later in the script or later in an entirely dseparate session?
In any case, you want something like:
Hope this helps, Chrisuse strict; use DBI; # # ... connect to DB, execute the SELECT # statement to the statement handle $sth... # # This method is slower than selecting an # arrayref, but it has the benefit of being # easy to understand # 'KEY_FIELD' is the name of your key field, # 'DATA_FIELD' is the name of the data field # you want to save my %records = (); while ( my $row = $sth->fetchrow_hashref ) { $records{ $row->{'KEY_FIELD'} } = $row->{'DATA_FIELD'}; } # You can now do anything you want with # %records and use the information without # dealing with the database. # ...later... print "Records retrieved:\n"; while ( my ( $key, $value ) = each %records ) { print "$key --> $value\n"; }
|
|---|