in reply to symbolic references

Hahaha, well, greet is a string constant. Its is not a variable

Why is that significant? Is the following code different somehow?

use strict; use warnings; use 5.010; sub greet { say 'hello'; } sub test { my $str = "greet"; goto &{$str}; #SYMBOLIC REFERENCE } test();

I'm still dereferencing something that is not a hard reference, {$str}, ergo according to "Programming Perl" the "value" is a symbolic reference. And it's my understanding that the only way perl can find the greet() subroutine is by looking in the symbol table--because the string 'greet' does not point to a subroutine somewhere in memory.

Replies are listed 'Best First'.
Re^2: symbolic references
by Anonymous Monk on Jan 01, 2011 at 09:56 UTC
Re^2: symbolic references
by chromatic (Archbishop) on Jan 01, 2011 at 18:25 UTC
    Is the following code different somehow?

    Yes. Perl 5 doesn't perform dataflow analysis to prove that $str can't possible change between assignment and the symbolic reference.

    I can think of a way to make test call a function besides greet without personally writing any XS.