line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::MyPerl; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
81593
|
use Moo; |
|
3
|
|
|
|
|
48615
|
|
|
3
|
|
|
|
|
19
|
|
4
|
3
|
|
|
3
|
|
8429
|
use IO::All; |
|
3
|
|
|
|
|
50715
|
|
|
3
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.003000'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'App::MyPerl::Role::Script'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub run { |
11
|
0
|
|
|
0
|
0
|
|
my @perl_options = @{$_[0]->perl_options}; |
|
0
|
|
|
|
|
|
|
12
|
0
|
0
|
|
|
|
|
print "@perl_options . \n" if $_[0]->_env_value('DEBUG'); |
13
|
0
|
|
|
|
|
|
exec($^X, @perl_options, @ARGV); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
1; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
App::MyPerl - Your very own set of perl defaults, on a global or per |
21
|
|
|
|
|
|
|
project basis |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# .myperl/modules |
26
|
|
|
|
|
|
|
v5.14 |
27
|
|
|
|
|
|
|
strictures |
28
|
|
|
|
|
|
|
autodie=:all |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$ myperl bin/some-script |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Runs some-script with the following already loaded |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use v5.14; |
35
|
|
|
|
|
|
|
use strictures; |
36
|
|
|
|
|
|
|
use autodie qw(:all); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
and through the magic of L, C and C |
39
|
|
|
|
|
|
|
are already in C<@INC> but files loaded from there will behave as if they |
40
|
|
|
|
|
|
|
had those lines in them, too. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
It is possible to add global defaults, to all scripts and all C |
43
|
|
|
|
|
|
|
projects with C<~/.myperl/defaults/modules> and C<~/.myperl/always/modules> |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
A C<.pm or .pl> file usually requires some preamble to get some defaults right. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# important ones |
50
|
|
|
|
|
|
|
use strict; |
51
|
|
|
|
|
|
|
use warnings; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# good |
54
|
|
|
|
|
|
|
use autodie qw(:all); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# better exceptions |
57
|
|
|
|
|
|
|
use Try::Tiny; |
58
|
|
|
|
|
|
|
use Carp; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
On top of that you might find L, L useful all over |
61
|
|
|
|
|
|
|
your code. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
C allows you define this boilerplate once and for all, while |
64
|
|
|
|
|
|
|
B with existing code. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 TUTORIAL |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If there is no C, C<~/.myperl> is by |
69
|
|
|
|
|
|
|
default read for global defaults. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# ~/.myperl/always/modules |
72
|
|
|
|
|
|
|
strictures |
73
|
|
|
|
|
|
|
autodie=:all |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# ~/.myperl/defaults/modules |
76
|
|
|
|
|
|
|
v5.14 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ~/some_scripts/script.pl |
79
|
|
|
|
|
|
|
say "Hello World" |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The syntax for the modules file is, |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
C -- # comment |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
C |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
C -- This translates to C |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
C<-Foo=bar,qux,baz> -- This translates to C |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=back |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Now, |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$ myperl ~/some_scripts/script.pl |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
will print C. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Let's say you are working on a typical Perl module like, |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
.myperl/ |
112
|
|
|
|
|
|
|
lib/ |
113
|
|
|
|
|
|
|
t/ |
114
|
|
|
|
|
|
|
bin/ |
115
|
|
|
|
|
|
|
README |
116
|
|
|
|
|
|
|
LICENSE |
117
|
|
|
|
|
|
|
Makefile.PL |
118
|
|
|
|
|
|
|
... |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Now, |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$ cd $project_dir; myperl bin/app.pl |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
will configure perl in such a way that C and C, will all |
125
|
|
|
|
|
|
|
have the preamble defined in C<.myperl/modules> and |
126
|
|
|
|
|
|
|
C<~/.myperl/always/modules> thanks to the import hooks in |
127
|
|
|
|
|
|
|
L. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If you don't have a C<.myperl/modules>, myperl will use |
130
|
|
|
|
|
|
|
C<~/.myperl/defaults/modules> in place of it. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can configure the directory C<$project_dir/.myperl> with |
133
|
|
|
|
|
|
|
C. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Running tests, |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$ myprove t/foo.t |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
And in your C - |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub MY::postamble { |
142
|
|
|
|
|
|
|
q{distdir: myperl_rewrite |
143
|
|
|
|
|
|
|
myperl_rewrite: create_distdir |
144
|
|
|
|
|
|
|
myperl-rewrite $(DISTVNAME) |
145
|
|
|
|
|
|
|
}; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
(warning: this is make - so the indent for the C line needs |
149
|
|
|
|
|
|
|
to be a hard tab) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
to have the defaults added to the top of C<.pm, .t and bin/*> files in your |
152
|
|
|
|
|
|
|
dist when it's built for CPAN. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Sometimes though, you want a module to be used during development, |
155
|
|
|
|
|
|
|
B. A good case |
156
|
|
|
|
|
|
|
for this is C. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
For this, add C<-indirect> in C<$project_dir/.myperl/dev-modules>. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
To specify modules loaded only into the top level script, prepend C |
161
|
|
|
|
|
|
|
to the file name - so C<$project_dir/.myperl/script-modules> specifies |
162
|
|
|
|
|
|
|
modules only used for the top level script, and C |
163
|
|
|
|
|
|
|
the same but not rewritten onto scripts when myperl-rewrite is invoked. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
And lastly, you can add C in |
166
|
|
|
|
|
|
|
C<$MYPERL_HOME/defaults/script-dev-modules> for having |
167
|
|
|
|
|
|
|
C conveniently preloaded for oneliners |
168
|
|
|
|
|
|
|
- see L for how this behaves in detail. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHOR |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
mst - Matt S. Trout (cpan:MSTROUT) |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
mucker - (cpan:MUCKER) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Copyright (c) 2013 the App::MyPerl L and L |
181
|
|
|
|
|
|
|
as listed above. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 LICENSE |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This library is free software and may be distributed under the same terms |
186
|
|
|
|
|
|
|
as perl itself. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |