in reply to hash refrences
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' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash refrences
by tilly (Archbishop) on Jan 18, 2011 at 01:30 UTC | |
by fennec (Initiate) on Feb 04, 2011 at 19:28 UTC | |
|
Re^2: hash refrences
by luckysing (Novice) on Jan 18, 2011 at 01:28 UTC |