How to get total keys available count in a single hash in Perl?
Method 1:
%final=(9,5,3,1,4);
scalar keys %final;
Method 2:
%final=(9,5,3,1,4);
print $a=keys %hash;
Method 3:
%final=(9,5,3,1,4);
@d=keys %final;
print scalar @d;
Method 4:
%final=(9,5,3,1,4);
$c=@d=keys %final;
print $c;
Method 5:
%final=(9,5,3,1,4);
@d=keys %final;
print $#d + 1;
Method 6:
%final=(9,5,3,1,4);
$z=0;
foreach(values %final) {
$z++;
}
print $z;
Method 7:
%final=(9,5,3,1,4);$a=0;
for($j = 0; $j < scalar keys %final; $j++) {
$a++;
}
print $a;
Method 8:
%final=(9,5,3,1,4);
$a=0;
map {$a++ } keys %final;
print $a;
Method 9:
%final=(9,5,3,1,4);
$b=++$a for keys %final;
print $b;
%final=(9,5,3,1,4);
scalar keys %final;
Method 2:
%final=(9,5,3,1,4);
print $a=keys %hash;
Method 3:
%final=(9,5,3,1,4);
@d=keys %final;
print scalar @d;
Method 4:
%final=(9,5,3,1,4);
$c=@d=keys %final;
print $c;
Method 5:
%final=(9,5,3,1,4);
@d=keys %final;
print $#d + 1;
Method 6:
%final=(9,5,3,1,4);
$z=0;
foreach(values %final) {
$z++;
}
print $z;
Method 7:
%final=(9,5,3,1,4);$a=0;
for($j = 0; $j < scalar keys %final; $j++) {
$a++;
}
print $a;
Method 8:
%final=(9,5,3,1,4);
$a=0;
map {$a++ } keys %final;
print $a;
Method 9:
%final=(9,5,3,1,4);
$b=++$a for keys %final;
print $b;
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home