Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: subroutine refs

by HelenCr (Monk)
on Sep 14, 2013 at 11:44 UTC ( #1054098=note: print w/replies, xml ) Need Help??

in reply to Re: subroutine refs
in thread subroutine refs

broquaint: This is amazing. I was looking for such a solution for a while.

Thinking about it, is this canonical? (namely, documented)? or is it a quirk (an oversight in the Perl language design?)

Replies are listed 'Best First'.
Re^3: subroutine refs
by Athanasius (Chancellor) on Sep 15, 2013 at 06:45 UTC

    Removing the intermediate assignment to $name, broquaint’s code simplifies to:

    use strict; my $subref = \&{'dynamic'}; &$subref(); sub dynamic { print "Mmm, dynamic.\n"; }

    which is explicitly documented as an exception to the normal behaviour of strict 'refs' (see strict):

    There is one exception to this rule:

    $bar = \&{'foo'}; &$bar;

    is allowed so that goto &$AUTOLOAD would not break under stricture.

    So, yes, this is canonical.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054098]
[stevieb]: 16.96 hours of runtime of a Raspberry Pi on a 12v, 7.2Ah battery :) Now to watch now long it takes to recharge the battery completely with my 18v solar cells in the sun :)
[stevieb]: my high-range estimate was 18 hours

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-03-26 15:18 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.