I lifted the following out of (IIRC) CGI.pm, and it works on this XP SP1
m/c:-

  if (($^O eq 'MSWin32') or ($^O =~ /cygwin/i)) { ...

I don't *know* that the Cygwin leg of the compare works, but considering
where I got it, why wouldn't it?!

Rgds, GStC. 

-----Original Message-----
From: Daniel Kasak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 16, 2005 6:25 PM
To: Chris Devers; Tim Johnson; beginners@perl.org
Subject: Re: Detect platform

Chris Devers wrote:

>On Wed, 16 Feb 2005, Tim Johnson wrote:
>
>  
>
>>On Wed, 16 Feb 2005, Daniel Kasak wrote:
>>
>>    
>>
>>>How do I detect what platform I'm running from inside a Perl script?
>>>      
>>>
>>Check out the $^O variable.
>>    
>>
> 
>...but be careful in writing code that matches it:
>
>Under Mac OSX:
>
>  $ perl -le 'print $^O'
>  darwin
>  $
>
>Under Cygwin on a Win2000 machine:
>
>  [EMAIL PROTECTED] ~
>  $ perl -le 'print $^O'
>  cygwin
>
>  [EMAIL PROTECTED] ~
>  $
>
>A CMD shell on the same machine:
>
>  C:\cygwin\usr\bin>perl -le 'print $^O'
>  perl -le 'print $^O'
>
>
>  C:\cygwin\usr\bin>
>
>Yes, it produced no output. I don't know why.
>
>I believe the Activestate version reports 'win32' or something, but I 
>don't have a copy handy to confirm that.
>
>Note that the string 'win' shows up in several different ways, so if 
>you just want to match on Windows (or win32, or win2000, or similar) 
>you have to make sure that you don't also catch the slightly different 
>Cygwin environment or the much different OSX one with the same pattern.
>  
>
Thanks guys :)

Luckily I have control over all PCs that will be running this app: 
Gentoo Linux and Windows 2000 with ActiveState Perl, maybe darwin down the
track ( if I can get Gtk2 modules working ).

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to