App-MyPerl

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    App::MyPerl - Your very own set of perl defaults, on a global or per
    project basis

SYNOPSIS
      # .myperl/modules
      v5.14
      strictures
      autodie=:all

      $ myperl bin/some-script

    Runs some-script with the following already loaded

      use v5.14;
      use strictures;
      use autodie qw(:all);

    and through the magic of lib::with::preamble, "lib/" and "t/lib/" are
    already in @INC but files loaded from there will behave as if they had
    those lines in them, too.

    It is possible to add global defaults, to all scripts and all "myperl"
    projects with "~/.myperl/defaults/modules" and
    "~/.myperl/always/modules"

DESCRIPTION
    A ".pm or .pl" file usually requires some preamble to get some defaults
    right.

      # important ones
      use strict;
      use warnings;

      # good
      use autodie qw(:all);

      # better exceptions
      use Try::Tiny;
      use Carp;

    On top of that you might find Scalar::Util, List::Util useful all over
    your code.

    "myperl" allows you define this boilerplate once and for all, while
    maintaining compatiability with existing code.

TUTORIAL
    If there is no "export MYPERL_HOME="~/.perl_defaults"", "~/.myperl" is
    by default read for global defaults.

      # ~/.myperl/always/modules
      strictures
      autodie=:all

      # ~/.myperl/defaults/modules
      v5.14

      # ~/some_scripts/script.pl
      say "Hello World"

    The syntax for the modules file is,

    *   "comment" -- # comment

    *   "empty space"

    *   "Foo=bar,qux,baz" -- This translates to "use Foo qw(bar, qux, baz)"

    *   "-Foo=bar,qux,baz" -- This translates to "no Foo qw(bar, qux, baz)"

    Now,

      $ myperl ~/some_scripts/script.pl

    will print "Hello World".

    Let's say you are working on a typical Perl module like,

      .myperl/
      lib/
      t/
      bin/
      README
      LICENSE
      Makefile.PL
      ...

    Now,

      $ cd $project_dir; myperl bin/app.pl

    will configure perl in such a way that "lib/**" and "t/lib/**", will all
    have the preamble defined in ".myperl/modules" and
    "~/.myperl/always/modules" thanks to the import hooks in
    lib::with::preamble.

    If you don't have a ".myperl/modules", myperl will use
    "~/.myperl/defaults/modules" in place of it.



( run in 2.127 seconds using v1.01-cache-2.11-cpan-d8267643d1d )