sub read_file { @_ == 2 or croak 'Incorrect number of parameters'; my $dbh = shift; my $source = shift; my $statement = sprintf(q{ SELECT NodeId , Title , Date , LastReputation , Reputation FROM %s }, $source, ); my $sth = $dbh->prepare($statement); $sth->execute; my %nodehash; while(my $row = $sth->fetchrow_hashref) { croak "Node ID $row->{NodeId} is duplicated!" if exists $nodehash{ $row->{NodeId} }; $nodehash{ $row->{NodeId} } = $row; } return \%nodehash; }