develooper Front page | perl.perl5.porters | Postings from May 2008

Special blocks below the top-level scope

Thread Next
From:
Aristotle Pagaltzis
Date:
May 8, 2008 04:38
Subject:
Special blocks below the top-level scope
Message ID:
20080508113832.GF4173@klangraum.plasmasturm.org
Hi all,

an interesting edge case I ran into in the course of looking at
the issue of labels named `BEGIN` etc is this:

    sub foo { my $foo; BEGIN { $foo = 1 } return $foo || '' }
    print "[$_]" for foo(), foo(), foo();

    =begin output

     [1]
     []
     []

I’m sure Abigail can find a use for this :-), but is it a regular
feature, an accidental one, or something else?

-- 
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>

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