http://qs321.pair.com?node_id=77682


in reply to No excuses about not using CGI.pm
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 CGI.pm
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 CGI.pm 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\g1.pl 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?
           MeowChow                                   
                       s aamecha.s a..a\u$&owag.print