Hi Suvajit Sengupta -
At 2005-11-16, 01:32:31 you wrote:
>Hi,
> How can I test whether a hash is empty or not ?
>For e.g: I have reference to a hash , say $preCommand and I get
> $preCommands as {} ,
> Its an empty hash, but it exists and is also defined.
>I need to check whether the hash is empty or not.
>Does anyone has any clue ?
>
>Regards,
>Suvajit
Try:
unless( keys %$preCommands ) {
...hash is empty...
}
You can use 'keys %hash' ( or if necessary 'scalar keys %hash' ) to
get a count of the number of hash elements just like @array for arrays.
Aloha => Beau;
[EMAIL PROTECTED]
2005-11-16
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>