in reply to Re: Is this a symbolic reference?
in thread Is this a symbolic reference?
The short version is that strict refs only applies to $%@* things, not &.
Your short version seems to be a little too short perhaps:
#!/usr/bin/perl -w use strict; sub foo { print "foo: @_\n" } my $symbolic = 'foo'; # This symbolic method invocation works in 5.6.1 # (but not in 5.00503) main->$symbolic; # foo: main # 'goto &$symbolic' works (in subroutines) sub bar { goto &$symbolic; # works # goto &{'foo'}; # works } bar(1,2,3); # But these symref calls don't work: &$symbolic; # ack! &{$symbolic}; # ook! &{"foo"}; # eek!
There clearly appears to be an exception for goto &{"symref"} in terms of symbolic-ref style *calls*.
The report you gave was slightly different --- taking a reference to a symbolically dereferenced subroutine works:
use strict; sub foo { print "foo: @_\n"; } my $bar = "foo"; &foo; # works # &{$bar}; # ack! symref as a call doesn't work my $sref = \&{$bar}; # works! $sref->(1,2,3); # foo: 1 2 3
The symbolic-deref for the purpose of taking a ref does indeed appear to be an exception that applies to & but not $%@*:
use strict; my $foo = "this is foo"; my $bar = "foo"; my $ref = \${$bar}; # ack!
|
|---|