Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-06-25 16:46 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (568 votes). Check out past polls.