Module:...Boolean(3)
hiii bestie! welcome to the manual page for Module:...Boolean(3) from the User Contributed Perl Documentation. itβs giving Boolean Representation Class, and itβs lowkey iconic. π
β¨
β¨ NAME β¨
Module::Generic::Boolean β the Boolean Representation Class, aka your little true/false bestie. π
π¦ SYNOPSIS π¦
okay so hereβs the whole vibe in code, no cap:
my $bool = Module::Generic::Boolean->true;
# or
my $bool = Module::Generic::Boolean::true;
# Now I have a Module::Generic::Boolean object
# Returns 1
if( $bool )
{
# Do something
}
my $hash =
{
name => 'John Doe',
active => $bool,
};
# Converting to json
print( JSON->new->encode( $hash ), "\n" );
# Would result in
{
name: "Jogn Doe",
active: true
}
π VERSION π
v1.2.2 β thatβs the version, bestie. β¨
πΈ DESCRIPTION πΈ
okay so this class/package is here to represent boolean values and make sure theyβre recognised interchangeably as Perl booleans, i.e. 1 or 0, or as JSON bools, i.e. "true" or "false". itβs giving bilingual but make it booleans. π
The code is taken and adapted from part of the JSON module. periodt. π₯
π METHODS π
hereβs the method menu, bestie β every single one, no skipping. π«Ά
π¦ as_array
Returns a Module::Generic::Array object with the current boolean value as its only entry. iconic little singleton behaviour. β¨
my $true = Module::Generic::Boolean->true;
my $a = $true->as_array;
say $a->[0]; # 1
π₯ as_number
Returns the current boolean value (1 or 0) as a Module::Generic::Number object. numbers found slaying. π
π as_scalar
Returns the current boolean value (1 or 0) as a Module::Generic::Scalar object. scalar era. π
β defined
Returns true. thatβs it. thatβs the whole method. iconic. π
π is_bool
Provided with a value, and this returns true if it is a Module::Generic::Boolean object. vibe check: passed. β
πΈ is_true
Provided with a value, and this returns true if it is a Module::Generic::Boolean object and this is true. true bestie behaviour. π
π¦ is_false
Provided with a value, and this returns true if it is a Module::Generic::Boolean object and this is false. respectful false recognition. π
π true
This returns a Perl true value, i.e. 1, or "true" when added into JSON. slay. β¨
π false
This returns a Perl false value, i.e. 0, or "false" when added into JSON. also slay. β¨
π
TO_JSON
This is called by JSON to transform an object into JSON data format. π«Ά
It returns "\1" if true, or "\0" otherwise. Those values are understood by JSON and transcoded accordingly. iykyk. π
π SERIALISATION π
Serialisation by CBOR, Sereal and Storable::Improved (or the legacy Storable) is supported by this package. To that effect, the following subroutines are implemented: FREEZE, THAW, STORABLE_freeze and STORABLE_thaw. literally serialisation main character energy. π
π§΅ THREAD SAFETY NOTE π§΅
Module::Generic::Boolean is thread-safe. ngl thatβs a flex. πͺ
Conversion methods like as_array, as_scalar, and as_number dynamically load external modules at runtime. To ensure maximum safety in multi-threaded environments, consider preloading those classes in the main thread:
use Module::Generic::Array;
use Module::Generic::Number;
use Module::Generic::Scalar;
These methods do not share state and are otherwise safe. no cap. β¨
π AUTHOR π
Jacques Deguest <jack@deguest.jp> β the author, bestie. π«Ά
π COPYRIGHT & LICENSE π
Copyright (c) 2000-2024 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
π cute sign-off: this page is fromperl v5.42.2, dated2026-02-15, and itβs allModule:...Boolean(3)β byeee, bestie! β¨π«Ά
π¦ where this page comes from
- alpine 3.24: perl-module-generic-doc 1.1.3-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms