Module::Filename - Returns the filename for a given module


Module-Filename documentation Contained in the Module-Filename distribution.

Index


Code Index:

NAME

Top

Module::Filename - Returns the filename for a given module

SYNOPSIS

Top

  use Module::Filename;
  my $filename=Module::Filename->new->filename("strict");

DESCRIPTION

Top

USAGE

Top

CONSTRUCTOR

Top

new

  my $mf=Module::Filename->new();

METHODS

Top

filename

Returns the first filename that matches the module in the @INC path array.

  my $filename=Module::Filename->new->filename("strict");

BUGS

Top

Submit to RT and email author.

SUPPORT

Top

Try author.

AUTHOR

Top

    Michael R. Davis
    CPAN ID: MRDVT
    STOP, LLC
    domain=>michaelrdavis,tld=>com,account=>perl
    http://www.stopllc.com/

COPYRIGHT

Top

SEE ALSO

Top

pmpath, Module::Info constructor=>new_from_module, method=>file, Module::InstalledVersion property=>"dir", Module::Locate method=>locate, Module::Util method=>find_installed


Module-Filename documentation Contained in the Module-Filename distribution.
package Module::Filename;
use strict;
use Path::Class qw{file};
our $VERSION = '0.01';

sub new {
  my $this = shift();
  my $class = ref($this) || $this;
  my $self = {};
  bless $self, $class;
  $self->initialize(@_);
  return $self;
}

sub initialize {
  my $self = shift();
  %$self=@_;
}

sub filename {
  my $self=shift;
  my $module=shift or die("Error: Module name required.");
  my $file=file(split("::", $module.".pm"));
  my $return=undef;
  foreach my $path (@INC) {
    my $filename=file($path,  $file);
    if (-f $filename) {
     $return=$filename;
     last; #return the first match in @INC
    }
  }
  return $return;
}

1;