consta...boolean(3pm)

πŸ“¦
version 0.02 Β· 3 versions
, in opensuse-leap 16.0

πŸ’– consta...boolean(3pm) πŸ’–

okay so bestie, welcome to the constant::boolean page β€” it's a User Contributed Perl Documentation gem, and honestly it's giving "small module, big main character energy" πŸŽ€


✨ NAME ✨

constant::boolean β€” literally just here to Define TRUE and FALSE constants. that's the whole vibe. slay.


🌸 SYNOPSIS 🌸

here's how you actually use it, no cap:

  use constant::boolean;

  use File::Spec;

  sub is_package_exist {
    my ($package) = @_;
    return FALSE unless defined $package;
    foreach my $inc (@INC) {
        my $filename = File::Spec->catfile(
            split( /\//, $inc ), split( /\::/, $package )
        ) . '.pm';
        return TRUE if -f $filename;
    };
    return FALSE;
  };

  no constant::boolean;

like, look at that. TRUE and FALSE doing their little thing in your own namespace. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so what it does: it defines the TRUE and FALSE constants in the caller's namespace. 🫢

and yes, technically you could just use simple values β€” like empty string or zero for false, or literally any non-empty and non-zero string value as true β€” but the TRUE and FALSE constants are way more descriptive. it's giving self-documenting code, iykyk.

it's virtually the same as this:

  # double "not" operator is used for converting scalar to boolean value
  use constant TRUE => !! 1;
  use constant FALSE => !! '';

okay and here's the actually useful bit πŸ‘‘: the constants exported by constant::boolean are not reported by Test::Pod::Coverage, so it is more convenient to use this module than to define TRUE and FALSE constants by yourself. no cap, that's the whole selling point.

and when you're done with them? the constants can be removed from class API with the no constant::boolean pragma or some universal tool like namespace::clean. clean exit, periodt ✨


πŸ’€ BUGS πŸ’€

If you find the bug or want to implement new features, please report it at <http://rt.cpan.org/NoAuth/Bugs.html?Dist=constant-boolean>

(that's the actual URL, don't come for me πŸ™ˆ β€” just drop your bug reports there)


🌈 AUTHOR 🌈

Piotr Roszatycki <dexter@cpan.org> πŸ’œ


⭐ LICENSE ⭐

Copyright 2008, 2009 by Piotr Roszatycki <dexter@cpan.org>.

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>


real talk bestie: the license terms and the Test::Pod::Coverage thing are the parts people actually get burned by, so don't skim those πŸ’–

and that's the page! 🧚 cute little sign-off for you: this one ships as perl v5.42.0, dated 2011-04-04, and yes she's still out here being consta...boolean(3pm) in the footer like the legend she is. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from