sanity
view release on metacpan or search on metacpan
README.html view on Meta::CPAN
name="NAME"
>NAME</a></h1>
<p>sanity - The ONLY meta pragma you'll ever need!</p>
<h1><a class='u'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre> use sanity;
use sanity 'strictures';
use sanity 'Modern::Perl';
use sanity qw(
strictures -warnings/uninitialized/FATAL
NO:autovivification NO:autovivification/store
PRINT_PRAGMA_HASH
);
use sanity '!0*b^Npow{8T7_yZt<?cT6/?ZCO=Y0LV_Duoc'; # Safer ASCII version
use sanity '¡0Dz鵆㤧뱞⡫瘑빸ን둈댬嚝⠨舁聼䮋'; # Shorter UTF8 version</pre>
<h1><a class='u'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>Modern::Perl? common::sense? no nonsense? use latest?</p>
<p>Everybody has their own opinion on what pragmas and modules are "required" for every person to use. These opinions turn into "personal pragmas", so that people don't have to type several <code>use</code> lines of header in fron...
<p>Personal opinions and pragmas don't really belong in the CPAN namespace. (It's CPAN, not Personal PAN. If you want a Personal PAN, go call Pizza Hut.) But copying code on potentially hundreds of modules doesn't make sense, either.</p>
<p>That was my mentality when I had a personal opinion of my own. Why repeat the same problem like everybody else?</p>
<p>This "sanity" module attempts to level the playing field by making it a <b>customizable</b> personal pragma, allowing you to both reduce the code needed and still implement all of the modules/pragmas you need.</p>
<p>As an illustration to what it's capable of, this pragma will emulate all of the other personal pragmas, most of them 100% working exactly how they do it.</p>
<h1><a class='u'
name="PARAMETERS"
>PARAMETERS</a></h1>
<p>Sanity's parameters fall into three types: flags, aliases, and hashes. (Oh my!)</p>
<h2><a class='u'
name="Flags_and_Aliases"
>Flags and Aliases</a></h2>
<p>Flags are single pragma/module declarations, strict/warning flags, or other items that need flags. Aliases are merely one or more flags, grouped together to better emulate the pragma/module's functionality.</p>
<p>Let's start off with an example:</p>
<pre> # These three statements do the same thing as...
use Modern::Perl;
use sanity 'Modern::Perl';
use sanity qw(strict warnings mro/dfs feature IO::File IO::Handle);
# ...these statements
use strict;
use warnings;
use mro 'dfs';
use feature ':all';
use IO::File;
use IO::Handle;</pre>
<p>Basically, it does the same thing as the meta pragma <a href="http://search.cpan.org/perldoc?Modern%3A%3APerl" class="podlinkpod"
>Modern::Perl</a>, except you actually don't need that module for it to work. While there is some magic to make sure, say, <code>feature</code> gets loaded with various versions of Perl, it typically just works using a standard <code>import</code...
<h3><a class='u'
name="Negating_flags/aliases"
>Negating flags/aliases</a></h3>
<p>You can turn off flags in the statement:</p>
<pre> use sanity qw(Modern::Perl -mro/dfs);</pre>
<p>This does the same thing as above, except it doesn't import the <code>mro</code> pragma. You can negate any flag, including combined aliases, as long as it makes sense. In other words, you need a positive included before you can negate somethi...
<h3><a class='u'
name="NO:*_flags/aliases"
>NO:* flags/aliases</a></h3>
<p>Some pragmas work by using the <code><b>unimport</b></code> function, so that the English makes sense. To keep that syntax, these pragmas are included with a <code>NO:</code> prefix:</p>
<pre> use sanity 'NO:multidimensional';
use sanity 'NO:indirect/FATAL';</pre>
<p>This will run the <code>unimport</code> function on these pragmas, even though sanity was called via the <code>import</code> function (via <code>use</code>).</p>
<h3><a class='u'
name="Perl_versions"
>Perl versions</a></h3>
<p>Sanity also supports Perl versions as a special kind of alias to specify minimum Perl versions:</p>
<pre> # These are all the same:
use v5.10.1;
use sanity 'v5.10.1';
use sanity v5.10.1; # as a VSTRING
use sanity 5.10.1; # works too
# Upgrade the Perl version of your favorite pragma
use sanity qw(NO:nonsense v5.12);</pre>
<p>Note that the version must be at least v5.8. This should be fine for most people. (If I get a ticket requesting support for a Perl version older than one released in 2002, I will hunt you down and break your keyboard in half.)</p>
<h3><a class='u'
name="The_Default"
>The Default</a></h3>
<p>What does <code>sanity</code> do without any parameters? Why my personal preference, of course :) It's listed in the <code>meta pragma</code> section of the <a href="#LIST_OF_FLAGS" class="podlinkpod"
>"LIST OF FLAGS"</a> below. I detail the reasons behind my choices <a href="http://search.cpan.org/perldoc?sanity%3A%3Asanity" class="podlinkpod"
>here</a>.</p>
<h2><a class='u'
name="Hashes"
>Hashes</a></h2>
<p>So, there's all of these flags, but unless you're using one of the combined aliases, typing them all out is usually just as much (or more) code as the several lines of <code>use</code> statements. Well, they are all flags so that it fits i...
<p>This number can be calculated using the flag <code>PRINT_PRAGMA_HASH</code>:</p>
( run in 1.074 second using v1.01-cache-2.11-cpan-fe3c2283af0 )