http://www.perlmonks.org?node_id=988608


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

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.

Replies are listed 'Best First'.
Re^5: undef/defined &{$name} while "strict refs"
by Anonymous Monk on Aug 21, 2012 at 07:22 UTC

    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.