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) ? Thanks Chanan -----Original Message----- From: [email protected] [mailto:[email protected]] 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 ….. defined($hash{key5}) 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… Thanks Chanan _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl
