I think the approach you take sort of deoends on the structure of your data. If your data looks like this
Code:
identifier1 id1field1 id1field2 id1field3
identifier2 id2field1 id2field2 id2field3
then you can use associative arrays that key off of the identifier, and store the fields as an array in the other side of the the hash pairs e.g.
Code:
# %database{identifier1} => ('id1field1, id1field3, id1field3,);
@fields = ($field1, $field2, $field3);
$database{$identifier} = \@fields;
That way the identifier is basically the primary key (which must be unique) and looking up things based on that key is easy. Querying based other pieces of data means iterating through hash though.
Code:
@results;
foreach $record (keys(%database)) {
foreach $field (@$database{$record}) {
if( $field eq $myquery) {
push(@results, $record);
}
}
}
Does that help? If I've been unclear or you need anything else, just ask.