NAME
true - automatically return a true value when a file is required
SYNOPSIS
package Contemporary::Perl;
use strict;
use warnings;
use true;
sub import {
strict->import();
warnings->import();
true->import();
}
DESCRIPTION
Perl's require
builtin (and its use
wrapper) requires the files it loads to return a true value. This is usually accomplished by placing a single
1;
statement at the end of included scripts or modules. It's not onerous to add but it's a speed bump on the Perl novice's road to enlightenment. In addition, it appears to be a non-sequitur to the uninitiated, leading some to attempt to mitigate its appearance with a comment:
1; # keep require happy
or:
1; # Do not remove this line
or even:
1; # Must end with this, because Perl is bogus.
This module packages this "return true" behaviour so that it need not be written explicitly. It shouldn't be used directly, except, perhaps, for pedagogical purposes. Rather it is intended to be invoked from the import
method of a Modern::Perl-style module that enables modern Perl features and conveniences and cleans up legacy Perl warts.
METHODS
import
This method, which takes no arguments, should be invoked from the import
method of a module that loads true
. Code that uses this module solely on behalf of its caller can load true
without importing it e.g.
use true (); # don't import
sub import {
true->import();
}
1;
But there's nothing stopping a wrapper module also importing true
to obviate its own need to explicitly return a true value:
use true; # both load and import it
sub import {
true->import();
}
# no need to return true
EXPORT
None by default.
SEE ALSO
AUTHOR
chocolateboy, <chocolate@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by chocolateboy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.