App-MyPerl
view release on metacpan or search on metacpan
lib/App/MyPerl.pm view on Meta::CPAN
package App::MyPerl;
use Moo;
use IO::All;
our $VERSION = '0.003000';
with 'App::MyPerl::Role::Script';
sub run {
my @perl_options = @{$_[0]->perl_options};
print "@perl_options . \n" if $_[0]->_env_value('DEBUG');
exec($^X, @perl_options, @ARGV);
}
1;
=head1 NAME
App::MyPerl - Your very own set of perl defaults, on a global or per
project basis
=head1 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 L<lib::with::preamble>, C<lib/> and C<t/lib/>
are already in C<@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 C<myperl>
projects with C<~/.myperl/defaults/modules> and C<~/.myperl/always/modules>
=head1 DESCRIPTION
A C<.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 L<Scalar::Util>, L<List::Util> useful all over
your code.
C<myperl> allows you define this boilerplate once and for all, while
B<maintaining compatiability> with existing code.
=head1 TUTORIAL
If there is no C<export MYPERL_HOME="~/.perl_defaults">, C<~/.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,
=over
=item *
C<comment> -- # comment
=item *
C<empty space>
=item *
C<Foo=bar,qux,baz> -- This translates to C<use Foo qw(bar, qux, baz)>
=item *
C<-Foo=bar,qux,baz> -- This translates to C<no Foo qw(bar, qux, baz)>
=back
Now,
$ myperl ~/some_scripts/script.pl
will print C<Hello World>.
Let's say you are working on a typical Perl module like,
.myperl/
lib/
t/
bin/
README
LICENSE
Makefile.PL
( run in 1.446 second using v1.01-cache-2.11-cpan-39bf76dae61 )