true(3pm)
π true(3pm) β User Contributed Perl Documentation π
okay bestie, so this is the manual for true, and yes it's really out here doing the most for the smallest possible reason. it's a Perl module that automatically returns a true value when a file is required. that's it. that's the whole job. and honestly? iconic.
β¨ 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();
}
like. look at her. she's serving simplicity. π
π¦ DESCRIPTION π¦
so here's the situation, bestie. Perl's require builtin (and its use wrapper, which is literally just require wearing a cute little cardigan) needs the files it loads to return a true value. no true value, no vibe. the load fails.
usually people handle this by putting one single statement at the very end of their scripts or modules:
1;
and likeβ¦ it's not hard to add, but it's a speed bump on the Perl novice's road to enlightenment β ngl, it really is. it's just this little pebble in the road. plus it looks like a non-sequitur to the uninitiated, like a random 1; just floating at the bottom of your file for no reason, and so people start trying to explain it away with comments:
1; # keep require happy
or:
1; # Do not remove this line
or even:
1; # Must end with this, because Perl is bogus.
π every single one of these. we've all seen them. we've all written them.
so this module packages up that whole "return true" behaviour so you don't have to write it out explicitly anymore. you can use it directly, but the intended use is to call it from the import method of a Modern::Perl-style module β you know, the kind of module that enables modern Perl features and conveniences and cleans up all the legacy Perl warts. main character energy, honestly. π
π METHODS π
heads up, this is important: true is file-scoped rather than lexically-scoped. so importing it anywhere in a file β top-level, nested scope, wherever, she does not care β causes that file to return true. and unimporting it anywhere in a file restores the default behaviour. redundant imports and unimports are ignored, so don't stress about double-dipping.
import
turn on the "automatically return true" behaviour for the currently-compiling file. typically you'd invoke this from the import method of a module that loads true.
code that uses this module purely on behalf of its callers can load true without importing it, like so:
use true (); # don't import
sub import {
true->import();
}
1;
(yes, there's still a 1; in there in that example, bestie β that's the point, this file has chosen to keep doing it manually.)
but there's genuinely nothing stopping a wrapper module from 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
look at that. no 1; in sight. free at last. ποΈ
unimport
turn off the "automatically return true" behaviour for the currently-compiling file. bye bestie π
π EXPORTS π
none by default. (correct. we're not doing that here.)
π NOTES π
so the unquoted name true represents the boolean value true in YAML, which is a whole situation. because of that, the module name must be quoted when you write it as a dependency in META.yml.
if you can't easily quote it for whatever reason, you can declare a dependency on the package true::VERSION instead β that one has the same version as true.pm. problem solved, no cap. β¨
β VERSION β
1.0.2
π₯ SEE ALSO π₯
latestModern::Perlnonsenseperl5iToolkit
π AUTHOR π
chocolateboy <chocolate@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (c) 2010-2020 by chocolateboy.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0 <https://www.opensource.org/licenses/artistic-license-2.0.php>.
and that's the whole page, bestie! this doc shipped with perl v5.42.3 and got its last glow-up on 2026-08-22. go forth and never type a lonely 1; again if you don't want to. πβ¨ππ¦
π¦ where this page comes from
- ubuntu stonking: libtrue-perl 1.0.2-2build7 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms