use strict; use warnings; use Data::Dumper; my $emp_data = { "bob" => { salary => 38.7, # in k$/yr sales => 23, # units }, "jane" => { salary => 50.3, sales => 36, } }; my $bref = comp($emp_data); print Dumper($bref); sub comp { my $data = shift; my %bonus; for my $e (keys %{ $data }) { if ($data->{$e}{sales} > 30) { my $b = 0.20 * $data->{$e}{salary}; $bonus{$e} = $b; } } return \%bonus; } __END__ $VAR1 = { 'jane' => '10.06' };
In reply to Re: hash refrences
by toolic
in thread hash refrences
by luckysing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |