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

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2016-10-27 15:18 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (365 votes). Check out past polls.