in reply to data structure problem

Another Way To Do It - an array_ref of hashes:
$countryMap = [ { shortcountry => 'US', country => 'USA', currency => 'USD', }, { shortcountry => 'D', country => 'Germany', currency => 'DM', }, .... ];
This is basically a flatfile db in memory - and can be easily saved to a file using Data::Dumper. The problem is getting the data out. I don't see a single step way to do this, but hey, we're optimising for developer time here, not cpu / memory. I'd do
sub getem { my $data = shift; my $find = shift; my $in = shift; my $return = shift; for (@$data) { if ($_->{$in} eq $find) { return $_->{$return}; } } }
Then to find 'US' with 'USA',
my $result = getem($countryMap,'US','country','shortcountry');


§ George Sherston