Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: notabug quiz

by liz (Monsignor)
on Dec 12, 2003 at 08:42 UTC ( #314254=note: print w/ replies, xml ) Need Help??


in reply to notabug quiz

sub Foo::INIT { print "Hello world\n" } &Foo::INIT;

I think I'm responsible for this one, more or less. For a while I was thinking that BEGIN, CHECK, INIT and END were actually subroutines. Well, they aren't. They're "magic" code blocks, that just happen to allow a "sub" prefix to confuse the hell out of everybody. Which is where the obfuscation In the BEGINning is based on.

Note that you can actually call subroutines named BEGIN, CHECK, INIT or END, but you need a special action to get them defined:

*Foo::INIT = sub { print "Hello world\n" }; &Foo::INIT; __END__ Hello world

Liz


Comment on Re: notabug quiz
Select or Download Code
Re: Re: notabug quiz
by ysth (Canon) on Dec 12, 2003 at 09:45 UTC
      Those magical codeblocks are detectable via caller EXPR though. This is a point in favour of subs in the "codeblocks vs. subs" dilemma.
      --kap

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314254]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2014-08-23 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (173 votes), past polls