any - use any modules in the list that are available


any documentation Contained in the any distribution.

Index


Code Index:

NAME

Top

any - use any modules in the list that are available

SYNOPSIS

Top

  use any 'Foo', 'Bar', 'Baz';

DESCRIPTION

Top

Given a list of modules (see first for what arguments it can take, ignores '-croak') it attempts to load each one.

The successful ones are in @any::module and the failed ones are in the $any::failed hashref which is the same as $first::failed

SEE ALSO

Top

first

AUTHOR

Top

Daniel Muey, http://drmuey.com/cpan_contact.pl

COPYRIGHT AND LICENSE

Top


any documentation Contained in the any distribution.

package any;

use strict;
use warnings;

use Carp;
use version;our $VERSION = qv('0.0.1');

our @module;
our $failed = {};

sub import {
    shift;
    local $UNIVERSAL::Level = $UNIVERSAL::Level + 1; 
    local $Carp::CarpLevel  = $Carp::CarpLevel  + 1;

    my @flags = map { $_ if $_ ne '-croak' } grep(/^-/, @_);
    @module = ();
    $failed = {};
    
    for my $mod (grep(!/^-/, @_)) {
        use first $mod, @flags;   
        push @module, $first::module if $first::module;
        $failed->{ $mod } = $first::failed->{ $mod } if exists $first::failed->{ $mod };
    }
}

1;

__END__