Wiggins d Anconia wrote:
Wiggins,
just one more thing, how can i get the number of elements from an hash
like this one that i'm
trying to use?
foreach my $keys (keys %{ $printers{jobs} }) {
You can take the list in a scalar context, or force it into a scalar
context, such as,
my $num = keys %{ $printers{jobs} };
or the more verbose,
my $num = scalar keys %{ $printers{jobs} };
'values' works in place of 'keys' since it is a 1-to-1 relationship,
keys is my preferred.
Don't forget the oft forgot and more efficient
print scalar %hash;
eg.
my %hash = (
A => 1, B => 2, C => 3
);
print scalar %hash;
=> 3/8
Randy.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>