Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: undef/defined &{$name} while "strict refs"

by Anonymous Monk
on Aug 21, 2012 at 06:43 UTC ( #988598=note: print w/ replies, xml ) Need Help??


in reply to Re^2: undef/defined &{$name} while "strict refs"
in thread undef/defined &{$name} while "strict refs"

I think, however, it's still unclear why defined/undef &{ 'run' } doesn't throw exceptions while "strict refs". ,/i>

Have you read what strict says about refs?

Please read it now


Comment on Re^3: undef/defined &{$name} while "strict refs"
Re^4: undef/defined &{$name} while "strict refs"
by anazawa (Beadle) on Aug 21, 2012 at 07:04 UTC
    The POD says we are allowed to get a reference to CODE using symbolic references while "strict refs". I think this doesn't mean we can defined or undef subroutines as well. I may be misreading the document.

      I think this doesn't mean we can defined or undef subroutines as well.

      I don't understand what you're saying here

        When we execute my code above, the script throws an exception because &{ 'run' } violates "strict refs". Khen1950fx explained how to avoid this problem (I appreciate his suggestion).

        On the other hand, when we comment out &{ 'run' }, my script doesn't output error messages. This result shows the following doesn't violate "strict refs":
        my $walkable = defined &{ 'walk' }; undef &{ 'walk' };
        It seems each line uses symbolic references. I don't understand why this is possible.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-08-31 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls