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

Special blocks below the top-level scope

Thread Next
Aristotle Pagaltzis
May 8, 2008 04:38
Special blocks below the top-level scope
Message ID:
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


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}
#Aristotle Pagaltzis // <>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About