in reply to Re: the #include business
in thread the #include business
After studying chromatic's sample code, I see why what you propose is not quite sufficient. You need to either have a BEGIN{} block around the "require" or use a "use"--which is very close to a "require" inside a BEGIN.
The reason for this is that the "require" is processed at run time and the $x variable used in test1.pl does not get defined until the test2.pl is compiled. Unfortunately, it never gets to test2.pl because the $x causes an error during the compile of test1.pl.
Putting the "require" in a BEGIN solves this by forcing test2.pl to be compiled (and $x to be declared) before the rest of test1.pl (and the usage of $x).
I have tended to use "use" instead of "require" since it became available in Perl, so didn't think of this problem until seeing chromatic's response.
-- Eric Hammond
|
---|