Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: weaken CODEREF

by Athanasius (Chancellor)
on Nov 11, 2013 at 02:52 UTC ( #1061944=note: print w/replies, xml ) Need Help??

in reply to weaken CODEREF

I can confirm this behaviour on perl 5.18.1 with Scalar::Util 1.35. Looks like a bug to me.

Note that the correct behaviour can be obtained using the experimental “lexical subroutines” feature, introduced in perl 5.18.0 (see perlsub):

#! perl use strict; use warnings; use feature 'lexical_subs'; use Scalar::Util 'weaken'; my $ref; { my sub frobnicate { print 42; } my $local_ref = \&frobnicate; # $ref = $local_ref; weaken($ref = $local_ref); } $ref->();


12:49 >perl The lexical_subs feature is experimental at line 10. Can't use an undefined value as a subroutine reference at +line 20. 12:49 >

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://1061944]
[atcroft]: stevieb: I have berrybrew installed on a Win machine, and I noticed that with perlbrew you can "upgrade" a particular installed version... any chance of doing something similar in the
[atcroft]: future with berrybrew?

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-04-29 05:09 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.