Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: No excuses about not using

by grinder (Bishop)
on May 03, 2001 at 19:45 UTC ( #77682=note: print w/replies, xml ) Need Help??

in reply to No excuses about not using
in thread variables not posting?

Furthermore, if you don't like looking at all that scary stuff at the beginning of your script, you can place those BEGIN { } code blocks at the end of your script. Won't make a whiff of difference, it'll run just the same.

Randal is right, heed his advice.

g r i n d e r

Replies are listed 'Best First'.
Re: Re: No excuses about not using
by merlyn (Sage) on May 03, 2001 at 19:49 UTC
    Not quite. The import can import prototypes, which need to sucked in before the rest of the code is compiled. Maybe not true for in particular, but I like to show a general template that can be copied for other problems without fear.

    -- Randal L. Schwartz, Perl hacker

      Actually in general I consider avoiding unexpected prototype conversion a good thing. In which case having a good way to silently ignore unwanted prototypes (and trust me, I rarely want them) is a good thing!
        But it's not silent (under -w):
        mysub(1); BEGIN { package Foo; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(mysub); sub mysub ($) { print "mysub: @_\n" }; } BEGIN { Foo->import(); } ## Output main::mysub() called too early to check prototype at C:\Projects\GPerl +\Test\ line 1. mysub: 1
        Though I don't quite understand, if BEGIN blocks are executed before the rest of the containing file is parsed (so sayeth perlmod), why does this happen at all?
                       s aamecha.s a..a\u$&owag.print

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-12-07 22:45 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (34 votes). Check out past polls.