in reply to Inheritance in Hash
Miguel#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inheritance in Hash
by ikegami (Patriarch) on Apr 21, 2005 at 04:21 UTC | |
by Miguel (Friar) on Apr 21, 2005 at 18:09 UTC |