.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "true 3pm" .TH true 3pm "2018-11-02" "perl v5.28.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" true \- automatically return a true value when a file is required .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package Contemporary::Perl; \& \& use strict; \& use warnings; \& use true; \& \& sub import { \& strict\->import(); \& warnings\->import(); \& true\->import(); \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Perl's \f(CW\*(C`require\*(C'\fR builtin (and its \f(CW\*(C`use\*(C'\fR wrapper) requires the files it loads to return a true value. This is usually accomplished by placing a single .PP .Vb 1 \& 1; .Ve .PP 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 \fInon-sequitur\fR to the uninitiated, leading some to attempt to mitigate its appearance with a comment: .PP .Vb 1 \& 1; # keep require happy .Ve .PP or: .PP .Vb 1 \& 1; # Do not remove this line .Ve .PP or even: .PP .Vb 1 \& 1; # Must end with this, because Perl is bogus. .Ve .PP This module packages this \*(L"return true\*(R" behaviour so that it need not be written explicitly. It can be used directly, but it is intended to be invoked from the \f(CW\*(C`import\*(C'\fR method of a Modern::Perl\-style module that enables modern Perl features and conveniences and cleans up legacy Perl warts. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" \&\f(CW\*(C`true\*(C'\fR is file-scoped rather than lexically-scoped. Importing it anywhere in a file (e.g. at the top-level or in a nested scope) causes that file to return true, and unimporting it anywhere in a file restores the default behaviour. Redundant imports/unimports are ignored. .PP \fIimport\fR .IX Subsection "import" .PP Enable the \*(L"automatically return true\*(R" behaviour for the currently-compiling file. This should typically be invoked from the \f(CW\*(C`import\*(C'\fR method of a module that loads \f(CW\*(C`true\*(C'\fR. Code that uses this module solely on behalf of its callers can load \f(CW\*(C`true\*(C'\fR without importing it e.g. .PP .Vb 1 \& use true (); # don\*(Aqt import \& \& sub import { \& true\->import(); \& } \& \& 1; .Ve .PP But there's nothing stopping a wrapper module also importing \f(CW\*(C`true\*(C'\fR to obviate its own need to explicitly return a true value: .PP .Vb 1 \& use true; # both load and import it \& \& sub import { \& true\->import(); \& } \& \& # no need to return true .Ve .PP \fIunimport\fR .IX Subsection "unimport" .PP Disable the \*(L"automatically return true\*(R" behaviour for the currently-compiling file. .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" None by default. .SH "NOTES" .IX Header "NOTES" Because some versions of \s-1YAML::XS\s0 may interpret the key of \f(CW\*(C`true\*(C'\fR as a boolean, you may have trouble declaring a dependency on true.pm. You can work around this by declaring a dependency on the package true::VERSION, which has the same version as true.pm. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 latest .IP "\(bu" 4 Modern::Perl .IP "\(bu" 4 nonsense .IP "\(bu" 4 perl5i .IP "\(bu" 4 Toolkit .IP "\(bu" 4 uni::perl .SH "AUTHOR" .IX Header "AUTHOR" chocolateboy, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2010\-2011 by chocolateboy .PP 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.