Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

true(3pm) [debian man page]

true(3pm)						User Contributed Perl Documentation						 true(3pm)

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 can be used directly, but 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 "true" 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. import Enable the "automatically return true" behaviour for the currently-compiling file. This should typically be invoked from the "import" method of a module that loads "true". Code that uses this module solely on behalf of its callers 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 unimport Disable the "automatically return true" behaviour for the currently-compiling file. EXPORT None by default. NOTES
Because some versions of YAML::XS may interpret the key of "true" 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. SEE ALSO
o latest o Modern::Perl o nonsense o perl5i o Toolkit o uni::perl AUTHOR
chocolateboy, <chocolate@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2010-2011 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. perl v5.14.2 2011-04-18 true(3pm)

Check Out this Related Man Page

boolean(3pm)						User Contributed Perl Documentation					      boolean(3pm)

NAME
boolean - Boolean support for Perl SYNOPSIS
use boolean; do &always if true; do &never if false; do &maybe if boolean($value)->isTrue; and: use boolean ':all'; $guess = int(rand(2)) % 2 ? true : false; do &something if isTrue($guess); do &something_else if isFalse($guess); and: use boolean -truth; die unless ref(42 == 42) eq 'boolean'; die unless ("foo" =~ /bar/) eq '0'; DESCRIPTION
Most programming languages have a native "Boolean" data type. Perl does not. Perl has a simple and well known Truth System. The following scalar values are false: $false1 = undef; $false2 = 0; $false3 = 0.0; $false4 = ''; $false5 = '0'; Every other scalar value is true. This module provides basic Boolean support, by defining two special objects: "true" and "false". RATIONALE
When sharing data between programming languages, it is important to support the same group of basic types. In Perlish programming languages, these types include: Hash, Array, String, Number, Null and Boolean. Perl lacks native Boolean support. Data interchange modules like YAML and JSON can now "use boolean" to encode/decode/roundtrip Boolean values. FUNCTIONS
This module defines the following functions: true This function returns a scalar value which will evaluate to true. The value is a singleton object, meaning there is only one "true" value in a Perl process at any time. You can check to see whether the value is the "true" object with the isTrue function described below. false This function returns a scalar value which will evaluate to false. The value is a singleton object, meaning there is only one "false" value in a Perl process at any time. You can check to see whether the value is the "false" object with the isFalse function described below. boolean($scalar) Casts the scalar value to a boolean value. If $scalar is true, it returns "boolean::true", otherwise it returns "boolean::false". isTrue($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::true" object. Returns "boolean::false" otherwise. isFalse($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::false" object. Returns "boolean::false" otherwise. isBoolean($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::true" or "boolean::false" object. Returns "boolean::false" otherwise. METHODS
Since true and false return objects, you can call methods on them. $boolean->isTrue Same as isTrue($boolean). $boolean->isFalse Same as isFalse($boolean). USE OPTIONS
By default this module exports the "true", "false" and "boolean" functions. The module also defines these export tags: :all Exports "true", "false", "boolean", "isTrue", "isFalse", "isBoolean" -truth You can specify the "-truth" option to override truth operators to return "boolean" values. use boolean -truth; print ref("hello" eq "world"), " "; Prints: boolean "-truth" can be used with the other import options. AUTHOR
Ingy doet Net <ingy@cpan.org> COPYRIGHT
Copyright (c) 2007, 2008, 2010, 2011. Ingy doet Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2011-09-12 boolean(3pm)
Man Page