Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

Output:

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

Hope that helps,

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061944]
help
Chatterbox?
[vedagiri89]: hi all! i need your help
[vedagiri89]: i'm facing this issue: Attempt to reload DynaLoader.pm aborted.\ nCompilation failed in require at /usr/lib64/perl5/ vendor_perl//APR. pm line 19.\nBEGIN failed--compilatio n aborted at /usr/lib64/perl5/ vendor_perl//APR. pm line 19.
[vedagiri89]: how do fix this issue
[choroba]: This usually happens when you have more than one version of Perl, and you mix the libraries
[hippo]: Which O/S?
[vedagiri89]: i have searched many forum...not getting resolutions
[vedagiri89]: centos
[Corion]: vedagiri89: Either what choroba said, or maybe you misspelled some module name (on Windows), like use Strict; or something like that.
[vedagiri89]: @choroba, what to do for that

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2018-06-19 11:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?