NAME
File::PM2File - find the absolute file for an unloaded program module
SYNOPSIS
use File::PM2File
($abs_file, $inc_path, $require) = File::PM2File->pm2file($pm)
($abs_file, $inc_path) = File::PM2File->find_in_include($file, [\@path])
$file = File::PM2File->pm2require($pm)
From time to time, an program needs to know the abolute file for a program module that has not been loaded. The File::PM2File module provides methods to find this information.
METHODS
find_in_include method
($abs_file, $inc_path) = File::PM2File->find_in_path($fspec, $file_relative, [\@path])
The find_in_path method looks for the $file_relative in one of the directories in the the @path (@INC path if @path not supplied) in the order listed. The file $file_relative may include relative directories. When find_in_include finds the file, it returns the absolute file $file_absolute and the directory $path where it found $file_relative.
pm2file method
($abs_file, $inc_path) = File::PM2File->pm2file($pm_file)
The pm2file method returns the absolute file and the directory in @INC for a the program module $pm_file.
pm2require
$file = File::PM2File->pm2require($pm_file)
The pm2require method returns the file suitable for use in a Perl require given the $pm_file file.
REQUIREMENTS
Coming soon.
DEMONSTRATION
~~~~~~ Demonstration overview ~~~~~
Perl code begins with the prompt
=>
The selected results from executing the Perl Code follow on the next lines. For example,
=> 2 + 2
4
~~~~~~ The demonstration follows ~~~~~
=> use File::Spec;
=> use File::Package;
=> my $fp = 'File::Package';
=> my $pm = 'File::PM2File';
=> my $loaded = '';
=> my $errors = $fp->load_package( 'File::PM2File' )
=> $errors
''
=> $pm->pm2require( "$pm")
'File\PM2File.pm'
=> #######
=> # Use the test file as an example since no its absolue path
=> #
=> # Calculate the absolute file, relative file, and include directory
=> #
=> my $relative_file = File::Spec->catfile('t', 'File', 'PM2File.pm');
=> my $absolute_file = File::Spec->rel2abs(__FILE__);
=> $absolute_file =~ s=.t$=.pm=;
=> my $restore_dir = cwd();
=> chdir File::Spec->updir();
=> chdir File::Spec->updir();
=> my $include_dir = cwd();
=> chdir $restore_dir;
=> $include_dir =~ s=/=\\=g;
=> ######
=> # Put base directory as the first in the @INC path
=> #
=> my @restore_inc = @INC;
=> unshift @INC, $include_dir;
=> ######
=> # Use the method under Test to find the absolute file and include directory
=> #
=> my @actual = $pm->find_in_include( $relative_file );
=> @INC = @restore_inc;
=> [@actual]
[
'E:\User\SoftwareDiamonds\installation\t\File\PM2File.pm',
'E:\User\SoftwareDiamonds\installation'
]
=> @actual = $pm->pm2file( 't::File::PM2File' )
=> [@actual]
[
'E:\User\SoftwareDiamonds\installation\t\File\PM2File.pm',
'E:\User\SoftwareDiamonds\installation',
't\File\PM2File.pm'
]
QUALITY ASSURANCE
The module "t::File::PM2File" is the Software Test Description(STD) module for the "File::PM2File". module.
To generate all the test output files, run the generated test script, run the demonstration script and include it results in the "File::PM2File" POD, execute the following in any directory:
tmake -test_verbose -replace -run -pm=t::File::PM2File
Note that tmake.pl must be in the execution path $ENV{PATH}
and the "t" directory containing "t::File::PM2File" on the same level as the "lib" directory that contains the "File::PM2File" module.
NOTES
AUTHOR
The holder of the copyright and maintainer is
<support@SoftwareDiamonds.com>
COPYRIGHT NOTICE
Copyrighted (c) 2002 Software Diamonds
All Rights Reserved
BINDING REQUIREMENTS NOTICE
Binding requirements are indexed with the pharse 'shall[dd]' where dd is an unique number for each header section. This conforms to standard federal government practices, 490A ("3.2.3.6" in STD490A). In accordance with the License, Software Diamonds is not liable for any requirement, binding or otherwise.
LICENSE
Software Diamonds permits the redistribution and use in source and binary forms, with or without modification, provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
SOFTWARE DIAMONDS, http::www.softwarediamonds.com, PROVIDES THIS SOFTWARE 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWARE DIAMONDS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING USE OF THIS SOFTWARE, EVEN IF ADVISED OF NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE POSSIBILITY OF SUCH DAMAGE.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 86:
Unknown directive: =head