filename - Perl module to load files at compile-time, without BEGIN blocks.
# Instead of "BEGIN { require '/path/to/file.pm' }" # use the more succinct: use filename '/path/to/file.pm'; # Or, if you need to do include a file relative to the program: use FindBin qw($Bin); use filename "$Bin/../lib/Application.pm"; # Do it at runtime: filename->require('/path/to/file.pm'); # Throw it into a loop: say( 'Required: ', $_ ) foreach grep filename->require, @files;
This module came about because there was a need to include some standard boilerplate that included some configuration and application specific paths to all modules for an application, and to do it at compile time. Rather than repeating BEGIN { require ... } in every single entry point for the application, this module was created to simplify the experience.
BEGIN { require ... }
The intention is to have this module be equivalent to "require" in perlfunc, except that it's run at compile time (via "use" in perlfunc), rather than at runtime.
require( $filename = $_ )
Does the equivalent of "require" in perlfunc on the supplied $filename, or $_ if no argument is provided.
$filename
$_
Must be called as a class method: filename->require( $filename )
filename->require( $filename )
Please report any bugs or feature requests on the bugtracker website https://github.com/rkleemann/filename/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
This document describes version v0.20.007 of this module.
Bob Kleemann <bobk@cpan.org>
This software is Copyright (c) 2019 by Bob Kleemann.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install filename, copy and paste the appropriate command in to your terminal.
cpanm
cpanm filename
CPAN shell
perl -MCPAN -e shell install filename
For more information on module installation, please visit the detailed CPAN module installation guide.