Git Product home page Git Product logo

true's Introduction

true

Build Status CPAN Version

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 doesn't need to 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.

EXPORTS

None by default.

NOTES

Because the unquoted name true represents the boolean value true in YAML, the module name must be quoted when written as a dependency in META.yml. In cases where this can't easily be done, a dependency can be declared on the package true::VERSION, which has the same version as true.pm.

VERSION

1.0.2

SEE ALSO

AUTHOR

chocolateboy

COPYRIGHT AND LICENSE

Copyright © 2010-2021 by chocolateboy.

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.

true's People

Contributors

chocolateboy avatar jluis avatar schwern avatar wchristian avatar yanick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

true's Issues

Make fails

I am very much a perl newbie, I know very little about the system.

I am trying to install App/Lingua/BO/Wylie/Transliteration.pm which seems to be dependent on true.

I am getting an error on the install of true. This seems very surprising, so I am very open to something very fundamental and wrong with the perl installation. Running perl v5.30.2 on MacOS 11.3.1.

cpan error log:

force install true.pm                                                         
Running install for module 'true'
  CHOCOLATE/true-v1.0.2.tar.gz
  Has already been unwrapped into directory /Users/phil/.cpan/build/true-v1.0.2-0
  CHOCOLATE/true-v1.0.2.tar.gz
  Has already been prepared
Running make for C/CH/CHOCOLATE/true-v1.0.2.tar.gz
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- true.bs blib/arch/auto/true/true.bs 644
cc -c  -I/Users/phil/perl5/lib/perl5/darwin-thread-multi-2level/B/Hooks/OP/Annotation/Install -I/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/B/Hooks/OP/Check/Install -g -pipe -fno-strict-aliasing -fstack-protector-strong -DPERL_USE_SAFE_PUTENV -O3 -Wall -W   -DVERSION=\"v1.0.2\" -DXS_VERSION=\"v1.0.2\"  -iwithsysroot "/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE"   true.c
true.xs:8:10: fatal error: 'hook_op_check.h' file not found
#include "hook_op_check.h"
         ^~~~~~~~~~~~~~~~~
1 error generated.
make: *** [true.o] Error 1
  CHOCOLATE/true-v1.0.2.tar.gz
  /usr/bin/make -- NOT OK
Failed during this command:
 CHOCOLATE/true-v1.0.2.tar.gz                 : make NO

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.