The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Module::Info::File - retrieves module information from a file or script

SYNOPSIS

use Module::Info::File;

my $module = Module::Info::File->new_from_file('path/to/Some/Module.pm');

$mod->name();

$mod->version();

$mod->file();

$mod->inc_dir();

DESCRIPTION

Module::Info (SEE REFERENCES), are lacking functionality of being able to extract certain data when parsing a module directly from a file. I have therefor created Module::Info::File, which inherits from Module::Info and replaces the new_from_file method so the lacking data can be accessed (dir and name attributes). Apart from that you can use all the neat accessors from Module::Info.

In the bin folder in this distribution is a small script called version.pl, which was the beginning of everything.

new_from_file

Given a file, it will interpret this as the module you want information about. You can also hand it a perl script.

After construction has been completed three attributes have been set in the object:

  • name

  • dir

  • file

So by using the inherited methods from Module::Info you can access the attributes.

There is an example in the bin/ folder called version.pl, this script was the starting point for this module.

  • name, returns the package name of the file.

  • version, returns the version number of the module/file in question ($VERSION).

  • inc_dir, returns the dir attribute

  • file, returns the file attribute

Please refer to the documentation on Module::Info for more details.

In the t/ directory of this distribution there is a test (Info.t), it includes some tests. These tests will test your installation of Module::Info (required by Module::Info::File), if the tests fail, Module::Info::File will be obsolete and can be discontinued.

SEE ALSO

  • Module::Info, by Mattia Barbon

  • bin/version.pl

CAVEATS

The module cannot handle several package definitions in one file and only uses the first one it encounters.

ACKNOWLEDGEMENTS

  • Lars Thegler (LTHEGLER), for not letting me go easily and a patch

  • Thomas Eibner (THOMAS), for reviewing the POD

  • Mattia Barbon (MBARBON), for writing Module::Info

  • bigj at Perlmonks who mentioned Module::Info

AUTHOR

jonasbn <jonasbn@cpan.org>

COPYRIGHT

Module::Info::File and related modules are free software and is released under the Artistic License. See <http://www.perl.com/language/misc/Artistic.html> for details.

Module::Info::File is (C) 2003 Jonas B. Nielsen (jonasbn) <jonasbn@cpan.org>