Identifying the OS in a Perl script

Shen ulist at gs1.ubuntuforums.org
Thu Sep 1 21:55:33 UTC 2005


Colin Watson Wrote: 
> Only if /usr/bin/env exists in Cygwin, which I suspect it doesn't ...



It is there, c:\cygwin\bin\env.exe, and it works the same. Other
Windows users could have .pl associated to an application, which would
run it anyway.



As for the first question, you can use

if ($^O =~ "Linux") {}

or ($^O eq /Windows/) {}. $^O, with a letter oh not a number zero,
holds the OS name.


-- 
Shen




More information about the ubuntu-users mailing list