|Home » Faqs » System » Check os|
There are many special, read-only perl variables accessible from anywhere in any perl script. One of them tells you the operating system the script is running in, as the following code demonstrates:
#!/usr/bin/perl use strict; use warnings; my $os = $^O; print "Running in: $os\n"; exit 0;
Under linux the output of this program would be:
Running in: linux
Under windows it would be:
Running in: MSWin32
See perldoc perlvar for more information.