perl -e 'print $^O'
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats. | [reply] [d/l] |
See perldoc perlvar and note the $^O variable. | [reply] [d/l] |
The quick answer, which you have recieved, is that $^O contains
the "name" of the OS. This is actually imprecise.
Particularly,
the value of $^O is compiled in, but $^O = MSWin32 on all of:
Win95, 98, me, NT, and 2k. That isn't very helpful. Worse, $^O isn't
write protected, meaning that someone could stick "MSWin32" in there when
you were expecting "bsdos" or "solaris".
Of course, for the most part $^O is sufficient. | [reply] |
As someone pointed out, the $^O variable may have been
set wrong. Another way to do it would be to check for
the existence of certain files - it looks like from your
example that you already know of two directories that
will be there. You could simply test for one or the other's
existence, as long as you had a guarantee that it existed
on one OS and did not exist on the other. A quick and dirty
fix, of course, but AWTDI. You may even want to test for
the location of perl.exe - very unlikely to be in the
same place on Windows and Linux. :)
| [reply] |
To go a bit further what turnstep explained, you may check the value of <kbd>$^X</kbd>, which is the path and name of your perl executable. If it ends in '.exe' it's likely you're running under Windows.
<kbd>--
PerlMonger::Paris(http => 'paris.pm.org');</kbd>
| [reply] |
Thanks a lot guys. I knew it was something dumb like that, but I searched the site and index of a couple books and couldn't find it. This site rules!!! | [reply] |
| [reply] |