[Israel.pm] FW: FW: check if hash is defined - without the keys

bc.other bc.other at gmail.com
Thu Jan 22 05:45:09 PST 2009

OK, found that I can use the if (%tvc or %tvw) with use strict / warnings it
works (no need for defined function).
I understood it returns a value ? but can anyone tell me what this value
represent ?

I tried this code:
my %tvc = (1 10);
my $sc = %tvc;

print $sc; --> printing 1/8 (does it means 1 key, 8 bytes) ?

-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf
Of Chanan Berler
Sent: Thursday, January 22, 2009 3:31 PM
To: 'Perl in Israel'
Subject: [Israel.pm] FW: check if hash is defined - without the keys

Hi All,

I got a hash with key1…key25, I am looking to know if the keys are defined
or not.
But I don't like the way like: if defined($hash{key1}) or …..

I also don't like much the idea of looping over the keys…
Q: is there a way to check if hash was defined or not….using the defined
function showed a warning…

PS: I can stop using the use strict / warnings – and try this if (%tvc or
%tvw) – and it works…
     But I still want to use them…


Perl mailing list
Perl at perl.org.il

More information about the Perl mailing list