Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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
Node Status?
node history
Node Type: note [id://77682]
holli gotta grab some groceries before dawn. l8ters
[erix]: s/dawn/dusk/
[erix]: (you're welcome :P)
[james28909]: you know, i had a thought a few mnths back. what if this universe were just a puzzle, waiting for life to figure it out!
[james28909]: what if one day we are able to grab the curtain that is "spacetime" and pull it back to reveal <insert imagination here> pulling at levers and ropes xD
[holli]: like dorothy?
[james28909]: see ya later holli
[james28909]: yeah like wizard of oz lol. its just a joke though
[james28909]: i cannot understand how someone cant see that a cloud of gas that evolves into a solar system or galaxies. it just makes sense to me. everythign that has happened, had to have happened for anything on this planet to be.
[james28909]: /gas/gas and debris/

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (14)
As of 2017-12-15 14:43 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.