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.



-- 
Chris Devers

-- 
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