in reply to standard perl module and BEGIN block.

I don't think I have used a BEGIN block more than 2-3 times in my career. *shrugs* YMMV.

As for who can take advantage of it ... well, other BEGIN blocks, CHECK blocks, INIT blocks ... again - I've never written a CHECK or INIT block in my career, and don't think I ever will. (Not in Perl5, at any rate.)

I don't know the history behind this construct, but I'm thinking it's very cargo-cultish.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: standard perl module and BEGIN block.

Replies are listed 'Best First'.
Re^2: standard perl module and BEGIN block.
by diotalevi (Canon) on Aug 16, 2004 at 18:48 UTC
    BEGIN is the sort of thing you write when you have code-generation tasks or want to otherwise have done work appropriate to a compile-time categorization. I wouldn't ordinarilly include things like setting $VERSION in that though there is some sense in including Exporter specific information at compile-time (even though it isn't code generation) - other things that have to run at compile-time are allowed to care about that information so it is potentially relavent at that time.