Daniel Muey > first-v0.0.1 > first

Download:
first-v0.0.1.tar.gz

Dependencies

Annotate this POD (1)

View/Report Bugs
Module Version: 0.0.1   Source  

NAME ^

first - use the first loadable module in a list

SYNOPSIS ^

  use first 'YAML::Syck', 'YAML::TINY', 'YAML';
  
  if( $first::module ) {
      print "Looks like I'll be using $first::module for this YAML..."
  }
  else {
      die "I have no YAML modules: $@";
  }
  
  my $yaml = $first::module->new();
  
  use first 'CGI::Simple', 'CGI::Minimal', 'CGI';
  my $cgi = $first::module ? $first::module->new() : $fallback_obj;

DESCRIPTION ^

Two main circumstances I've encountered where this is useful is:

ARGUMENTS ^

Arguments after 'use first' can be a name space string or an array reference whose first item is a name space and the rest is what would get passed to/after 'use Name::Space'

VARIABLES ^

These variables are available after 'use first' and are reset upon each call of 'use first' (Similar to how $@ is reset with every eval)

$first::module

Contains the namespace that was loaded, if any. undefined otherwise if none could be loaded.

$first::failed

Is a hashref whose keys are the name space that could not be loaded and the values are the given key's error message.

$@

Contains the last error, if any.

SEE ALSO ^

last, any, all, fake

TODO ^

More tests as per first.t

AUTHOR ^

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

COPYRIGHT AND LICENSE ^

Copyright (C) 2007 by Daniel Muey

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: