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

[MacPerl] conditional use of Mac::XXX.pm modules?



I'd like to write a script that runs under both UNIX and Macintosh,
while taking advantage of MacPerl's special features.  I can tell
whether I'm running under Mac OS easily enough:

require Config;
$OS = $Config::Config{'osname'};
$macintosh = ($OS =~ /^macos$/i);

I'd then like to include Mac OS-specific modules if $macintosh is
true.  But this doesn't work:

if ($macintosh)
{
	use Mac::StandardFile;
}


(It works on a Macintosh, of course; it doesn't work under UNIX, because
it fails at compile-time.)  Changing the code as follows works under both
systems:

if ($macintosh)
{
	eval "use Mac::StandardFile;";
}


But is this really the "right" way to do it?  Is there a better way?

--
Paul DuBois
paul@snake.net
Home Page: http://www.primate.wisc.edu/people/dubois
Software:  http://www.primate.wisc.edu/software



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch