develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #80628] [PATCH] __SUB__

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
December 12, 2010 12:52
Subject:
Re: [perl #80628] [PATCH] __SUB__
Message ID:
24F0BC28-C758-4C1A-B137-E7C9C03608BE@cpan.org

On Dec 12, 2010, at 12:36 PM, Abigail via RT wrote:

> On Sun, Dec 12, 2010 at 12:26:07PM -0800, Father Chrysostomos wrote:
>> # New Ticket Created by  Father Chrysostomos 
>> # Please include the string:  [perl #80628]
>> # in the subject line of all future correspondence about this issue. 
>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=80628 >
>> 
>> 
>> This patch adds a __SUB__ keyword that returns the current subroutine, or undef for the main program, a special block, or an eval.
>> 
>> If there are no objections, I will add docs and push this shortly before 5.13.8.
> 
> 
> Technically, it could break programs, as in theory someone could have a sub
> named '__SUB__'. It's not something I worry about though.

I thought such names were reserved.

> 
> I think this is going to be very handy. I see opportunity for obfuscation
> as well, but that's just my twisted mind.

Twisted, eh? How about this?

()=@==split" ","Just another Perl hacker,\n";
print reverse@=

@@=("Perl hacker,\n",'Just another '),
 ,       $@=sub{print$@[@_]}        ,
  ,         ()->$@,$@->()          ,

use constant{Just=>another=>Perl=>hacker=>};$\=",\n";
print join" ",map eval"sort $_,$_",qw!     Just Perl!

perl -e 'print do{{&{sub{"Just another Perl hacker,\n"}},last}}'

perl5.12.2 -e '$_{0+\$_}="Just another Perl hacker,\n";@INC=sub{\\$_};print$_{require _};sub SCALAR{$_[0]};'


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