develooper Front page | perl.perl5.porters | Postings from February 2015

Re: :const

Thread Previous | Thread Next
From:
Lukas Mai
Date:
February 9, 2015 16:53
Subject:
Re: :const
Message ID:
54D8E5F6.6010901@gmail.com
Am 25.01.2015 um 16:05 schrieb Ævar Arnfjörð Bjarmason:
> To elaborate on this a bit I also patched a distro of mine to change basically:
>
>      my $x = $y; no strict 'refs'; *$sub = sub { use strict 'refs'; $x };
>
> To:
>
>      my $x = $y; no strict 'refs'; *$sub = sub { $x };
>
> The language of the existing documentation doesn't guarantee that the
> former is inlined. I just wrote it like that because I have a habit of
> turning pragmas on/off only for the specific code that needs it.

If you want minimal pragma scope, how about

     my $x = $y; *{ no strict 'refs'; \*$sub } = sub { $x };

? :-)

-- 
Lukas Mai <plokinom@gmail.com>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About