[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] Multi Platform Scripts



On Mon, Aug 09, 1999 at 09:35:03AM -0500, Richard L. Grubb wrote:
> I working on a perl script that will be executed on at least a Mac and a
> UNIX box. When I try to run it on UNIX, the script fails because it
> cannot find Mac Specific modules, even though they are inside of if
> blocks that are not to be executed on a UNIX machine. How do I hide
> these use statements? Or do I just install dummy .pm files on my UNIX
> machine?

It doesn't matter what 'if' blocks a 'use' is inside, because 'use' is a
compile-time directive.

By replacing 'use' with 'require' and 'import', you get runtime execution
instead.


> # for Mac users who forget to drag&drop the input file
> if ($^O eq 'MacOS')
> {
>   if ($#ARGV < 0)
>   {
>     use Mac::StandardFile;
>     $file = StandardGetFile('', 'TEXT');
>     if ($file->sfGood())
>     {
>       push(@ARGV, $file->sfFile());
>     }
>     else
>     {   
>       exit(1);
>     }
>   }  
> }    

if ($^O eq 'MacOS') {
  require Mac::StandardFile;
  import Mac::StandardFile;
  ...
}


Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org