The first step is to check the output of the variable $^O
If the output is presented as an example
Linux
you need more processing to determine which distribution is being used.
See perldoc perlvar
So far, you can run lsb_release -a to find out which distribution is used.
If this command is not available, you can check for the presence of files such as:
/etc/debian_version
Other sample file tests: http://www.novell.com/coolsolutions/feature/11251.html
Consider also the xaxes solution using the Linux::Distribution module to test the distribution.
If you want to discover the package manager, you can try this approach:
if ($^O eq "linux") { my $pm; do{ if (-x qx(type -p $_ | tr -d "\n")) { $pm = $_; last; } } for qw/apt-get aptitude yum emerge pacman urpmi zypper/; print $pm; }
source share