On Wed, Jul 31, 2002 at 02:00:22PM -0700, Randall M! Gee wrote: > On 2002 Jul 31 (Wed) 15:55:09 -0400, > Chris Nandor <[EMAIL PROTECTED]> wrote: > > > > #!perl -wl > > use strict; > > > > runTestHarness(); > > > > BEGIN { > > if ($^O eq 'MacOS') { > > # now importing all the constants > > eval "use MacPerl qw(kMacPerlQuitIfFirstScript)"; > > } > > } > > > > sub runTestHarness { > > print kMacPerlQuitIfFirstScript; > > } > > > > It prints "3", as it should. > > Sure, it prints "3", but only on a Mac. Try it on a non-Mac machine. > You get an error, because kMacPerlQuitIfFirstScript is a bareword, and > you never did anything to tell Perl it's a function. > > I'm not sure what the best way to handle this is. I suspect the best > thing to do is to put all the functions that require Win32::IProcess > into a seperate module, and then conditionally include that module > if you're on a Windoze machine. But it depends on your code. It > may not be possible to divide things like this. > > You could also make sure that all your barewords are imported somehow.
Or, you could call all your barewords with parentheses: sub runTestHarness { print kMacPerlQuitIfFirstScript(); } that will avoid the bareword error, give you the proper value on a Mac, and cause a fatal error for calling an undefined subroutine elsewhere. Ronald