in reply to Re^2: named sub, subref and magic goto speed
in thread named sub, subref and magic goto speed

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; }->();

Replies are listed 'Best First'.
Re^4: named sub, subref and magic goto speed
by ysth (Canon) on Dec 14, 2006 at 09:51 UTC
    Sure there is; goto $label, where $label is an object expected to return a label string, and the object happens to be based on a coderef.