laziness, impatience, and hubris | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi Monks, "strict refs" declaration confuses me.
The declaration doesn't allow symbolic references.
The following code tries to call, undef and defined
subroutines using symbolic references while "strict refs".
The above output the following: According to perldiag, the above error message means: Only hard references are allowed by "strict refs". Symbolic references are disallowed. See perlref. I understand why the script throws an exception, but I'm not sure why defined/undef &{'walk'} are allowed. Are there any differences? Sincerely, UPDATE: I noticed &{ 'run' } calls run(), while defined/undef &{ 'walk' } never call walk(). I think that's the difference. PBP written by D. Conway says "18.7 Always use strict". In this section, \&{$DUMP} doesn't violate "strict refs" because the expression doesn't call dump_at(). I thank PBP :-) NOTE: PBP says "Never use symbolic references". This practice is undoubtedly reasonable. In reply to undef/defined &{$name} while "strict refs" by anazawa
|
|