Dave's Free Press

Technology: Devel-CheckApplicationCapabilities-1.1


Older stuff

Devel::CheckApplicationCapabilities - check what an external application is capable of.


Devel::CheckApplicationCapabilities - check what an external application is capable of.


Devel::CheckApplicationCapabilities provides a nice user-friendly interface to back-end modules for doing things like checking whether tar(1) supports the -z argument and so can be expected to support .tar.gz files.


    use Devel::CheckApplicationCapabilities qw(app_is);
    print "Yay, I can gzip!\n"
      if(app_is('tar' => qw(TarMinusZ)));
    print "Yay, I can bzip too!\n"
      if(app_is('tar' => qw(TarMinusJ TarMinusZ)));


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

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

Boolean functions


Takes an application name and a list of capabilities and returns true if the application has all the capabilities, false otherwise. The application can be specified as a relative path, a full path, or with no path at all in which case $ENV{PATH} will be searched.

Each capability corresponds to a Devel::AssertApplicationCapabilities::whatever module.


Exactly the same as app_is, except that it returns true if the app does not have all the capabilities, otherwise it returns false.

Fatal functions


As app_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.


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

And some utility functions ...


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. Yes, it says ``OS'', not ``application''. Sorry, that's just the way things are.


When called in list context, return a list of all the capabilities that can be checked, or Devel::AssertApplicationCapabilities::* modules that are available. That includes both those bundled with this module and any third-party add-ons you have installed.

In scalar context, returns a hashref keyed by capability with the filename of the most recent version of the supporting module that is available to you.

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


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

    perl -MDevel::CheckApplicationCapabilities=:all -le 'print join(", ", list_app_checks())'

Note that capitalisation is important. These are the names of the underlying Devel::AssertApplicationCapabilities::* modules which do the actual platform detection, so they have to be 'legal' filenames and module names, which unfortunately precludes funny characters, so we check for 'tar -z' with 'TarMinusZ'. Sorry.

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


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

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/






David Cantrell <david@cantrell.org.uk>




Copyright 2010 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.


I recommend buying splendiferous cloth from <http://www.dashingtweeds.co.uk/>, especially from their ``lumatwill'' range.


This module is also free-as-in-mason software.