NAME

Astro::App::Satpass2::Utils - Utilities for Astro::App::Satpass2

SYNOPSIS

use Astro::App::Satpass2::Utils qw{ instance };
instance( $foo, 'Bar' )
   or die '$foo is not an instance of Bar';

DESCRIPTION

This module is a grab-bag of utilities needed by Astro::App::Satpass2.

This module is private to the Astro::App::Satpass2 package. Any and all functions in it can be modified or revoked without prior notice. The documentation is for the convenience of the author.

All documented subroutines can be exported, but none are exported by default.

SUBROUTINES

This module supports the following exportable subroutines:

has_method

has_method( $object, $method );

This exportable subroutine returns a code reference to the named method if the given object has the method, or a false value otherwise. What you actually get is the result of $invocant->can( $method ) if the invocant is a blessed reference, or a return otherwise.

instance

instance( $object, $class )

This exportable subroutine returns a true value if $object is an instance of $class, and false otherwise. The $object argument need not be a reference, nor need it be blessed, though in these cases the return is false.

load_package

load_package( $module );
load_package( $module, 'Astro::App::Satpass2' );

This exportable subroutine loads a Perl module. The first argument is the name of the module itself. Subsequent arguments are prefixes to try, without any trailing colons.

In the examples, if $module contains 'Foo', the first example will try to require 'Foo', and the second will try to require 'Astro::App::Satpass2::Foo' and require 'Foo', in that order. The first attempt that succeeds returns the name of the module actually loaded. If no attempt succeeds, undef is returned.

Arguments are cached, and subsequent attempts to load a module simply return the contents of the cache.

quoter

quoter( $string )

This exportable subroutine quotes and escapes its argument as necessary for the parser. Specifically, if $string is:

* undef, 'undef' is returned;

* a number, $string is returned unmodified;

* an empty string, '' is returned;

* a string containing white space, quotes, or dollar signs, the value is escaped and enclosed in double quotes ("").

* anything else is returned unmodified.

SUPPORT

Support is by the author. Please file bug reports at http://rt.cpan.org, or in electronic mail to the author.

AUTHOR

Thomas R. Wyant, III wyant at cpan dot org

COPYRIGHT AND LICENSE

Copyright (C) 2011-2012 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.