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

[MacPerl] Re: Using NetPresenz and MacPerl



Michael Mogitz wrote:
>Hi - I have been using MacPerl for about a year to check cgi scripts before
>uploading them on our unix server for production use. Usually I can do a
>good job of testing and debugging on the mac. One of the tricks I use is to
>just set a variable like $onMac and if it's true, I set the environment
>variables that I will be using in the cgi.


It would be nice if Perl had a portable way to detect the platform that
it is running on.  Maybe there is a good way and I just don't know it.

Here's the trick that I came up with originally:
    
    $on_unix = $<;      # When running in test mode on the Mac, the PID
                        # will be zero; it will never be zero on Unix.
    
    if ( $on_unix ) {
        require 'cgi-lib.pl';
        # etc. etc.
    }

However, I hope that a future Mac might actually have a non-zero
process ID (preemptive multitasking! yes!) so what I'm using now is:
                                
    if ( $0 =~ /Macintosh HD/ ) {  # Test for something unique in where the
                                   # script resides on the Mac.
        $on_mac = 1;
    }


   -Paul-           paul.b.patton@hbc.honeywell.com