You can actually make the sample code more clear, with absolutely no variables defined:
This still gives you scalar.if (defined *{'main::test'}{SCALAR}) { print "scalar" ;} if (defined *{'main::test'}{ARRAY}) { print "array" ;} if (defined *{'main::test'}{HASH}) { print "hash" ;}
However once you use 'use strict' to disallow symbolic ref, this code throws error. I assume most of the people use 'use strict' all the time, so the failure of this testing is not really that scary.
On the other hand, to some level, it makes sense for this test to be successful for scalar, but not array and hash, as Perl subconsciously take a variable as scalar until it 'knows'.
In reply to Re: Symbol Table entry always return defined for {SCALAR}!!!
by pg
in thread Symbol Table entry always return defined for {SCALAR}!!!
by gmpassos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |