Oops! Good catch. I wonder how perl's not bailing out complaining
Because it DWYM instead. The docs say a label is expected, but if a code ref is provided, goto $ref is treated as goto &$ref. Personally, I consider it a bug in the docs (not in Perl or your code) because there's no reason to treat goto $ref as it if were goto "$ref".
$\ = "\n"; sub foo { print @_ } my $ref = \&foo; sub { @_=('$ref->(@_)'); $ref->(@_); }->(); sub { @_=('foo(@_)'); foo(@_); }->(); sub { @_=('goto $ref'); goto $ref; }->(); sub { @_=('goto &$ref'); goto &$ref; }->();
In reply to Re^3: named sub, subref and magic goto speed
by ikegami
in thread named sub, subref and magic goto speed
by shmem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |