I have two hashes which I use in my code. One,
Dumper \%userJobCount
$VAR1 = {
'hina' => 2,
'maccetta' => 1,
'vineethk' => 1,
'jpriyank' => 27,
'sanchars' => 1,
'kamran' => 8,
'wilt' => 7,
'sakir' => 5,
'rjernigan' => 8,
'emichael' => 1,
'ranjith' => 8,
'wgutknec' => 7,
'danchuy' => 1,
'saurabh4' => 1,
'chengc' => 9,
'revathi' => 2,
'zumach' => 7,
'hual' => 7,
'lkashyap' => 2,
'raviteja' => 17,
'bsheetal' => 4,
'horgan' => 2,
'tongz' => 6,
'demat' => 1,
'matthew6' => 14,
'alward' => 1,
'adalton' => 1,
'sydneyw' => 5,
'yashodhc' => 1,
'makam' => 1,
'surajs' => 9,
'radish' => 2,
'sudiptac' => 2,
'adityak' => 4,
'dodgson' => 4,
'sudipp' => 6,
'zaw' => 1,
'umeshr' => 23,
'zukas' => 6
};
and
%userJobSubtest = (
name => '',
username => '',
rc => PASS,
notes => ''
);
Here's the code where I use them:
foreach my $key (keys %userJobCount) {
if( $userJobCount{$key} > $jobLimit) {
%userJobSubtest = (
name => $key,
username => $key,
rc => WARN,
notes => ''
);
#print Dumper \%userJobSubtest;
push(@{$rtn{subtests}}, \%userJobSubtest);
}
}
print Dumper %rtn;
I'll just show the subtests key value from the total output:
$VAR6 = [
{
'rc' => 3,
'notes' => '',
'name' => 'umeshr',
'username' => 'umeshr'
},
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0],
$VAR6->[0]
];
In the code, this part is commented out:
#print Dumper \%userJobSubtest;
When I run this, it has the values of other keys whose values are more than the $jobLimit (= 5) Does anyone have an idea what's going wrong with the push? Why am I getting duplicate entries when what I am pushing shouldn't actually be the same value?
Dumper. For example,print Dumper %rtn;should beprint Dumper \%rtn;. In this case, print Dumper $rtn{subtests};` would be even better.