SPUG: Modules - more than one object in file?

Brian Ingerson briani at activestate.com
Thu Oct 12 12:04:22 CDT 2000


"Darren/Torin/Who Ever..." wrote:
> 
> I came in a bit late to say much but I did want to make a few comments.
> (Well, more than a few comments; my instructor side came out to play.)
> 
> Brian Ingerson, in an immanent manifestation of deity, wrote:
> >There seems to be a lot of fuzziness among the common Perl community, as
> >to what *order* Perl executes all of the source code that you give it.
> 
> It's really not fuzzy at all.  It is in a definitive order.  But I'll
> grant that some folks ideas about the order is fuzzy. :)

Darren,
I didn't state that the *order* was fuzzy, only many people's
*understanding* of it. I just wanted to present some code that would let
people visualize what was going on. Once you see it, the fog clears
quickly.

> 
> >Perlers talk about 'compile time' and 'run time', but in reality the two
> >are very much mixed together. For example you can use BEGIN blocks to
> >'run' code during 'compile' time, and eval blocks to 'compile' Perl
> >during 'run' time.
> 
> I disagree about them being mixed together.  All code gets turned into
> a parse tree during compile time.  Then, to run the code, Perl walks the
> parse tree executing the ops that it finds along the way.
> 
> Perl does want to be quite the enabler though.  :)  It gives you hooks
> so you can run code during compile time - why should the executable have
> all the fun?  That's the BEGIN statement.
> 
> Perl also doesn't want to be discriminatory.  It likes to enable you on
> both sides of the compile/run phase.  So, if in the middle of your
> running code, you'd like to call the compiler again, you can do that
> with eval.

In other words, they are mixed together. Just because there's a parse
tree involved, doesn't mean that there's a discrete compile time like in
Java. Code can be added to the parse tree with 'require' at run time,
and the parse tree can be executed before the so called compile time is
done. In fact, you could write your entire working program in a BEGIN
block and still have it *run* using 'perl -c'.

> Well, CHECK is a compile-time directive as well but that's recent.
> 
> >2) require Foo;
> >     is similar to:
> >   eval `cat Foo.pm`;
> 
> It's actually significantly more complicated than that.  The three

You seemed to have missed the *spirit* of message. It was merely to have
the reader look at Perl through a different set of glasses. Anyone who
sets out to *define* Perl behaviour in an email message will fail
miserably. Perl is that rich. That's why I like it.

Brian

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list