NAME

file - Perl module to load files at compile-time, without BEGIN blocks.

SYNOPSIS

# Instead of "BEGIN { require '/path/to/file.pm' }"
# use the more succinct:
use file '/path/to/file.pm';

# Or, if you need to do include a file relative to the program:
use FindBin qw($Bin);
use file "$Bin/../lib/Application.pm";

# Do it at runtime:
file->require('/path/to/file.pm');

# Throw it into a loop:
say( 'Required: ', $_ ) foreach grep file->require, @files;

DESCRIPTION

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.

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.

METHODS

require( $filename = $_ )

Does the equivalent of "require" in perlfunc on the supplied $filename, or $_ if no argument is provided.

Must be called as a class method: file->require( $filename )

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/rkleemann/file/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.

VERSION

This document describes version v0.20.007 of this module.

AUTHOR

Bob Kleemann <bobk@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Bob Kleemann.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)