And another way could be something like:
#!/usr/bin/perl -w
use strict;
my $data = {
Colour => 'blue',
Entries => {
Flowers => {
Dahlia => {
Smell => 'nice'
},
Rose => {
Colour => 'red'
}
}
}
};
my $ref_flowers = $data->{Entries}->{Flowers};
my $colour = sub{my $fl=shift; $ref_flowers->{$flw}->{Colour}};
my $smell = sub{my $fl=shift; $ref_flowers->{$flw}->{Smell}};
print "Rose's color is ",$colour->('Rose'),".\n" if $colour->('Rose');
print "Dahlia smells ",$smell->('Dahlia'),".\n" if $smell->('Dahlia');
__OUTPUT__
Rose's color is red.
Dahlia smells nice.
Miguel