my $dbh = DBI->connect('...', { RaiseError => 0 }) or die "Unable to connect to datasource: $DBI::errstr\n"; my $sth = $dbh->prepare('SELECT PK, Name, Memo...'); or die "Unable to prepare query statement: $DBI::errstr\n"; my $rv = $sth->execute() or die "Unable to execute query statement: $DBI::errstr\n"; my $data = $sth->fetchall_arrayref; my %hash = %{ &checksums($data) }; # some time later... foreach(@$data) { print "PK:\t", $_->[0], "\t"; print "Name:\t", $_->[1], "\t"; print "Digest:\t", $hash{$_->[0]}, "\n"; } sub checksums { my $recordset = shift; my %checksums; foreach(@$recordset) { $checksums{$_->[0]} = &digest($_->[2]); } return \%checksums; }