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

[long] Re: [MacPerl] Recommendations on how to port a MacPerlscript to Unix



-----BEGIN PGP SIGNED MESSAGE-----

At 18:39 +1000 on 23/10/97, Philippe de Rochambeau wrote:
>I would like to port a MacPerl script to Unix for CGI purposes.
Could
>someone please tell me what I should watch out for?

Check what operating system your script is running under:

	use English;
	if( $OSNAME="MacOS" )
	{
		<do something MacOS specific>
	};

According to perlvar.pod:

	$OSNAME
	$^O
	The name of the operating system under which this copy of
	Perl was built, as determined during the configuration
	process.  The value is identical to $Config{'osname'}.

Under solaris, $OSNAME="solaris". Under MacOS $OSNAME="MacOS". Under
Linux, $OSNAME="linux". I don't know about other platforms. To be
safe, try to make your comparison case insensitive, eg

	if( $OSNAME =~ m/solaris/i ) ...

Even though you *know* the name is capitalised one way, you might
have made a mistake, or you might just *know* wrong.

Under MacOS, the path separator is ":". Under Unix, the path
separator is "/". Either don't hard code any pathnames (store them
in a configuration file outside your source code), or build logic in
to your program to convert one type of file specification to the
other.

Don't ever use the system() function. This relies on certain
commands being available to your OS. MacPerl is smart enough to
realise that some commands actually mean something, but don't rely
on it. Just don't use system(). It's alright for people doing quick
and dirty hacks on Unix systems, but not for people using a clean
and disciplined OS like MacOS :-)

When returning stuff to the Web server, remember to use "\n" for
your end-of-lines, not "\013" or "\x0A". Perl on the Mac and Perl
under Unix will interpret "\n" to whatever it's supposed to be on
the target platform.

That's all I can think of right now. I'm sure everyone else has
other stuff to add :-)

Alex Satrapa
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2, by FileCrypt 1.0

iQCVAwUBNFCpaGFCmlEesL8FAQHxJAP/ZCR+zSQiARi/Fl7J6t9Te0PFwQrcy2cv
I5lSqPp+PbXBxy/BgqckpxymcprxVMilqqSF66Tcl0xawzQjKS+C+tuCr9OC2XVj
/uztp5djVrhGLXMgmv/8RrYWn8rptFPG9jdtds4VKZZXcxFmtC75KZRilfxEkvNq
yF3KIzhkuLA=
=ofiH
-----END PGP SIGNATURE-----

Windows 95: n. 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company.



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