At 12:26 -0700 2002.07.31, Andrew O. Mellinger wrote:
>   I have often done "require" instead in the past.  How would the
>require behavior compare to the non BEGIN usage?

Well, use Foo is essentially the same as:

        BEGIN { require Foo; import Foo }

Here is one quick example of the difference.  This prints "0":

        BEGIN { require MacPerl; import MacPerl }
        print kMacPerlNeverQuit;

However, this prints nothing:

        require MacPerl; import MacPerl;
        print kMacPerlNeverQuit;

The import needs to happen at compile-time for the function to be properly
"seen" so that the kMacPerlNeverQuit() function won't need the ().  If you
add warnings, you get:

# Name "main::kMacPerlNeverQuit" used only once: possible typo.
File 'Untitled #2'; Line 3
# print() on unopened filehandle kMacPerlNeverQuit.
File 'Untitled #2'; Line 3

Oops!  Adding the () to the end fixes it.

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to