in reply to Backward compatibility: $^O in perl 4

A possible solution may be to look at $ENV{'OSTYPE'}. The variable is set by the shell on most Unix systems and as such should serve your purpose.

Please realize that $ENV{'OSTYPE'} doesn't necessarily always contain the OS as well as the version. As an example, a machine of mine running FreeBSD 4.7 with perl 5.8.0 prints the following:

> perl -e 'print $ENV{'OSTYPE'}," ",$^O,$/' FreeBSD FreeBSD >
This is my only machine that reports without the version, but just a head's up in case.

Update: Ah, this is wonderful:
> uname FreeBSD >
So perhaps $ENV{'OSTYPE'} is just as good as attempting to capture the output from uname.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Replies are listed 'Best First'.
Re^2: Backward compatibility: $^O in perl 4 (uname is better)
by Aristotle (Chancellor) on May 07, 2003 at 16:36 UTC
    No, worse. uname is available on pretty much every flavour of Unixoid system under the sun, while the presence of $OSTYPE depends on additional factors.

    Makeshifts last the longest.