in reply to function encapsulation

A few points:

--ZZamboni

Replies are listed 'Best First'.
RE: Re: function encapsulation
by maverick (Curate) on Jul 13, 2000 at 19:35 UTC
    more points:
    • 'use' happens when the script is compiled
    • 'require' happens as the script runs
    So, if you make any changes to @INC, it won't effect any of the 'use' statements, but it will the 'require's.
    Also, if you 'perl -c' the script, the '.pm's that were 'use'd in will be checked for sytax, the ones that were 'require'd in won't be.

    /\/\averick

      That's not to say that you can't make changes to @INC which will affect 'use' statements. Two ways that spring to mind are:

      1. Put the code that changes @INC in a BEGIN block.
      2. Use use lib;
      --
      <http://www.dave.org.uk>

      European Perl Conference - Sept 22/24 2000, ICA, London
      <http://www.yapc.org/Europe/>
        True. You can also put the 'require's inside a BEGIN block and get their syntax checked by perl -c. I'm sure there's more examples we can think of...

        /\/\averick

      then this raises an interesting question (for me at least)

      i should probably test this myself (and probably will but love
      discussion ... and have a deadline breathing down my neck ;)

      if i make a function, and encapsulate it in a file, then
      make calls to that function from a script which had been
      compiled using perl2exe...
      would the whole program still work?
      could i change the required and encapsulated function as needed?
      is this the basic concept behind a DLL file in windows?
          or are there more to them?

      i've not got a lot comp-sci so i'm trying to pick up advanced topics
      in programming on the fly, while simultaniously learning the basics
      i'd love some help me in gaining a deeper understanding of the whole system
      we're working in