GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DEVEL::CHECKOS (3)

.ds Aq ’

NAME

Devel::CheckOS - check what OS we’re running on

CONTENTS

DESCRIPTION

A learned sage once wrote on IRC:



   $^O is stupid and ugly, it wears its pants as a hat



Devel::CheckOS provides a more friendly interface to $^O, and also lets you check for various OS families such as Unix, which includes things like Linux, Solaris, AIX etc.

It spares perl the embarrassment of wearing its pants on its head by covering them with a splendid Fedora.

SYNOPSIS



    use Devel::CheckOS qw(os_is);
    print "Hey, I know this, its a Unix system\n" if(os_is(Unix));

    print "Youve got Linux 2.6\n" if(os_is(Linux::v2_6));



USING IT IN Makefile.PL or Build.PL

If you want to use this from Makefile.PL or Build.PL, do not simply copy the module into your distribution as this may cause problems when PAUSE and search.cpan.org index the distro. Instead, use the use-devel-assertos script.

FUNCTIONS

Devel::CheckOS implements the following functions, which load subsidiary OS-specific modules on demand to do the real work. They can be exported by listing their names after use Devel::CheckOS. You can also export groups of functions thus:



    use Devel::CheckOS qw(:booleans); # export the boolean functions
                                      # and die_unsupported
   
    use Devel::CheckOS qw(:fatal);    # export those that die on no match

    use Devel::CheckOS qw(:all);      # export everything



    Boolean functions

os_is

Takes a list of OS names. If the current platform matches any of them, it returns true, otherwise it returns false. The names can be a mixture of OSes and OS families, eg ...



    os_is(qw(Unix VMS)); # Unix is a family, VMS is an OS



os_isnt

If the current platform matches any of the parameters it returns false, otherwise it returns true.

    Fatal functions

die_if_os_isnt

As os_is(), except that it dies instead of returning false. The die() message matches what the CPAN-testers look for to determine if a module doesn’t support a particular platform.

die_if_os_is

As os_isnt(), except that it dies instead of returning false.

    And some utility functions ...

die_unsupported

This function simply dies with the message OS unsupported, which is what the CPAN testers look for to figure out whether a platform is supported or not.

list_platforms

When called in list context, return a list of all the platforms for which the corresponding Devel::AssertOS::* module is available. This includes both OSes and OS families, and both those bundled with this module and any third-party add-ons you have installed.

In scalar context, returns a hashref keyed by platform with the filename of the most recent version of the supporting module that is available to you. This is to make sure that the use-devel-assertos script Does The Right Thing in the case where you have installed the module in one version of perl, then upgraded perl, and installed it again in the new version. Sometimes the old version of perl and all its modules will still be hanging around and perl helpfully includes the old perl’s search path in its own.

Unfortunately, on some platforms this list may have file case broken. eg, some platforms might return ’freebsd’ instead of ’FreeBSD’. This is because they have case-insensitive filesystems so things should Just Work anyway.

list_family_members

Takes the name of an OS ’family’ and returns a list of all its members. In list context, you get a list, in scalar context you get an arrayref.

If called on something that isn’t a family, you get an empty list (or a ref to an empty array).

PLATFORMS SUPPORTED

To see the list of platforms for which information is available, run this:



    perl -MDevel::CheckOS -e print join(", ", Devel::CheckOS::list_platforms())



Note that capitalisation is important. These are the names of the underlying Devel::AssertOS::* modules which do the actual platform detection, so they have to be ’legal’ filenames and module names, which unfortunately precludes funny characters, so platforms like OS/2 are mis-spelt deliberately. Sorry.

Also be aware that not all of them have been properly tested. I don’t have access to most of them and have had to work from information gleaned from perlport and a few other places. For a complete list of OS families, see Devel::CheckOS::Families.

If you want to add your own OSes or families, see Devel::AssertOS::Extending and please feel free to upload the results to the CPAN.

BUGS and FEEDBACK

I welcome feedback about my code, including constructive criticism. Bug reports should be made using <http://rt.cpan.org/> or by email.

You will need to include in your bug report the exact value of $^O, what the OS is called (eg Windows Vista 64 bit Ultimate Home Edition), and, if relevant, what OS family it should be in and who wrote it.

If you are feeling particularly generous you can encourage me in my open source endeavours by buying me something from my wishlist:
<http://www.cantrell.org.uk/david/wishlist/>

SEE ALSO

$^O in perlvar

perlport

Devel::AssertOS

Devel::AssertOS::Extending

Probe::Perl

The use-devel-assertos script

Module::Install::AssertOS

AUTHOR

David Cantrell <david@cantrell.org.uk>

Thanks to David Golden for the name and ideas about the interface, and to the cpan-testers-discuss mailing list for prompting me to write it in the first place.

Thanks to Ken Williams, from whose Module::Build I lifted some of the information about what should be in the Unix family.

Thanks to Billy Abbott for finding some bugs for me on VMS.

Thanks to Matt Kraai for information about QNX.

Thanks to Kenichi Ishigaki and Gabor Szabo for reporting a bug on Windows, and to the former for providing a patch.

Thanks to Paul Green for some information about VOS.

Thanks to Yanick Champoux for a patch to let Devel::AssertOS support negative assertions.

Thanks to Brian Fraser for adding Android support.

Thanks to Dale Evans for Debian detection, a bunch of Mac OS X specific version detection modules, and perl 5.6 support.

SOURCE CODE REPOSITORY

<git://github.com/DrHyde/perl-modules-Devel-CheckOS.git>

COPYRIGHT and LICENCE

Copyright 2007-2012 David Cantrell

This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It’s up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.

HATS

I recommend buying a Fedora from <http://hatsdirect.com/>.

CONSPIRACY

This module is also free-as-in-mason software.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DEVEL::CHECKOS (3) 2015-03-13

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.