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&#39;ll ever need!</p>

<h1><a class='u'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<pre>   use sanity;
   use sanity &#39;strictures&#39;;
   use sanity &#39;Modern::Perl&#39;;

   use sanity qw(
      strictures -warnings/uninitialized/FATAL
      NO:autovivification NO:autovivification/store
      PRINT_PRAGMA_HASH
   );
   use sanity &#39;!0*b^Npow{8T7_yZt&#60;?cT6/?ZCO=Y0LV_Duoc&#39;;  # Safer ASCII version
   use sanity &#39;&#161;0&#498;&#40262;&#14631;&#48222;&#10347;&#30225;&#48760;&#4757;&#46152;&#45868;&#22173;&#10280;&#33281;&#32892;&#19339;&#39;;  # 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 &#34;required&#34; for every person to use. These opinions turn into &#34;personal pragmas&#34;, so that people don&#39;t have to type several <code>use</code> lines of header in fron...

<p>Personal opinions and pragmas don&#39;t really belong in the CPAN namespace. (It&#39;s CPAN, not Personal PAN. If you want a Personal PAN, go call Pizza Hut.) But copying code on potentially hundreds of modules doesn&#39;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 &#34;sanity&#34; 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&#39;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&#39;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&#39;s functionality.</p>

<p>Let&#39;s start off with an example:</p>

<pre>   # These three statements do the same thing as...
   use Modern::Perl;
   use sanity &#39;Modern::Perl&#39;;
   use sanity qw(strict warnings mro/dfs feature IO::File IO::Handle);

   # ...these statements
   use strict;
   use warnings;
   use mro &#39;dfs&#39;;
   use feature &#39;:all&#39;;
   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&#39;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&#39;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 &#39;NO:multidimensional&#39;;
   use sanity &#39;NO:indirect/FATAL&#39;;</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 &#39;v5.10.1&#39;;
   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&#39;s listed in the <code>meta pragma</code> section of the <a href="#LIST_OF_FLAGS" class="podlinkpod"
>&#34;LIST OF FLAGS&#34;</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&#39;s all of these flags, but unless you&#39;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 )