line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ############################################################################## |
2
|
|
|
|
|
|
|
# # Script : Modern::PBP::Perl # |
3
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
4
|
|
|
|
|
|
|
# # Copyright : Free under 'GNU General Public License' or 'Artistic License' # |
5
|
|
|
|
|
|
|
# # Authors : JVBSOFT - Jürgen von Brietzke 0.001 - 1.240 # |
6
|
|
|
|
|
|
|
# # Version : 1.240 23.Mai.2016 # |
7
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
8
|
|
|
|
|
|
|
# # Function : Loading pragmas and Modules for 'Perl Best Practices'. # |
9
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
10
|
|
|
|
|
|
|
# # Language : PERL 5 (V) 5.12.xx - 5.24.xx # |
11
|
|
|
|
|
|
|
# # Coding : ISO 8859-15 / Latin-9 UNIX-lineendings # |
12
|
|
|
|
|
|
|
# # Standards : Perl-Best-Practices severity 1 (brutal) # |
13
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
14
|
|
|
|
|
|
|
# # Pragmas : feature, mro, strict, version, warnings # |
15
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
16
|
|
|
|
|
|
|
# # Module : Carp ActivePerl-CORE-Module # |
17
|
|
|
|
|
|
|
# # English # |
18
|
|
|
|
|
|
|
# # Exporter # |
19
|
|
|
|
|
|
|
# # IO::File # |
20
|
|
|
|
|
|
|
# # IO::Handle # |
21
|
|
|
|
|
|
|
# # ------------------------------------------------------------- # |
22
|
|
|
|
|
|
|
# # Perl::Version ActivePerl-REPO-Module # |
23
|
|
|
|
|
|
|
# ############################################################################## |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Modern::PBP::Perl 1.240; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# ############################################################################## |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
103275
|
use 5.012; |
|
2
|
|
|
|
|
6
|
|
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
7
|
use feature (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
21
|
|
32
|
2
|
|
|
2
|
|
824
|
use mro (); |
|
2
|
|
|
|
|
1188
|
|
|
2
|
|
|
|
|
39
|
|
33
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
31
|
|
34
|
2
|
|
|
2
|
|
767
|
use version; |
|
2
|
|
|
|
|
2497
|
|
|
2
|
|
|
|
|
12
|
|
35
|
2
|
|
|
2
|
|
97
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
38
|
|
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
2
|
|
7
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
134
|
|
38
|
2
|
|
|
2
|
|
829
|
use English qw{-no_match_vars}; |
|
2
|
|
|
|
|
3906
|
|
|
2
|
|
|
|
|
9
|
|
39
|
2
|
|
|
2
|
|
591
|
use Exporter; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
40
|
2
|
|
|
2
|
|
802
|
use IO::File; |
|
2
|
|
|
|
|
12339
|
|
|
2
|
|
|
|
|
189
|
|
41
|
2
|
|
|
2
|
|
10
|
use IO::Handle; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
54
|
|
42
|
2
|
|
|
2
|
|
932
|
use Perl::Version; |
|
2
|
|
|
|
|
5998
|
|
|
2
|
|
|
|
|
1679
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# ############################################################################## |
45
|
|
|
|
|
|
|
# # Feature/Warnings-Table : Contains all the features available to Perl 5.24 # |
46
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- # |
47
|
|
|
|
|
|
|
# # 5.xx <-> Feature is included in the feature tag ( ':5.xx' ) # |
48
|
|
|
|
|
|
|
# # ++++ <-> Feature can be switched on in Perl version # |
49
|
|
|
|
|
|
|
# # ---- <-> Feature is not implemented in the Perl version # |
50
|
|
|
|
|
|
|
# ############################################################################## |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
## no tidy |
53
|
|
|
|
|
|
|
# ------ Perl-Version ---- 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 ------------- |
54
|
|
|
|
|
|
|
our %FEATURES = ( |
55
|
|
|
|
|
|
|
array_base => [qw( 5.10 5.12 5.14 ++++ ++++ ++++ ++++ ++++ )], |
56
|
|
|
|
|
|
|
bitwise => [qw( ---- ---- ---- ---- ---- ---- ++++ ++++ )], |
57
|
|
|
|
|
|
|
current_sub => [qw( ---- ---- ---- 5.16 5.18 5.20 5.22 5.24 )], |
58
|
|
|
|
|
|
|
evalbytes => [qw( ---- ---- ---- 5.16 5.18 5.20 5.22 5.24 )], |
59
|
|
|
|
|
|
|
fc => [qw( ---- ---- ---- 5.16 5.18 5.20 5.22 5.24 )], |
60
|
|
|
|
|
|
|
lexical_subs => [qw( ---- ---- ---- ---- ++++ ++++ ++++ ++++ )], |
61
|
|
|
|
|
|
|
postderef => [qw( ---- ---- ---- ---- ---- ++++ ++++ ++++ )], |
62
|
|
|
|
|
|
|
postderef_qq => [qw( ---- ---- ---- ---- ---- ++++ ++++ 5.24 )], |
63
|
|
|
|
|
|
|
refaliasing => [qw( ---- ---- ---- ---- ---- ---- ++++ ++++ )], |
64
|
|
|
|
|
|
|
say => [qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 )], |
65
|
|
|
|
|
|
|
signatures => [qw( ---- ---- ---- ---- ---- ++++ ++++ ++++ )], |
66
|
|
|
|
|
|
|
state => [qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 )], |
67
|
|
|
|
|
|
|
switch => [qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 5.24 )], |
68
|
|
|
|
|
|
|
unicode_eval => [qw( ---- ---- ---- 5.16 5.18 5.20 5.22 5.24 )], |
69
|
|
|
|
|
|
|
unicode_strings => [qw( ---- 5.12 5.14 5.16 5.18 5.20 5.22 5.24 )], |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our %WARNINGS = ( |
73
|
|
|
|
|
|
|
autoderef => [qw( ---- ---- ---- ---- ---- 5.20 5.22 ---- )], |
74
|
|
|
|
|
|
|
bitwise => [qw( ---- ---- ---- ---- ---- ---- 5.22 5.24 )], |
75
|
|
|
|
|
|
|
const_attr => [qw( ---- ---- ---- ---- ---- ---- 5.22 5.24 )], |
76
|
|
|
|
|
|
|
lexical_subs => [qw( ---- ---- ---- ---- 5.18 5.20 5.22 5.24 )], |
77
|
|
|
|
|
|
|
lexical_topic => [qw( ---- ---- ---- ---- 5.18 5.20 5.22 ---- )], |
78
|
|
|
|
|
|
|
postderef => [qw( ---- ---- ---- ---- ---- 5.20 5.22 5.24 )], |
79
|
|
|
|
|
|
|
re_strict => [qw( ---- ---- ---- ---- ---- ---- 5.22 5.24 )], |
80
|
|
|
|
|
|
|
refaliasing => [qw( ---- ---- ---- ---- ---- ---- 5.22 5.24 )], |
81
|
|
|
|
|
|
|
regex_sets => [qw( ---- ---- ---- ---- 5.18 5.20 5.22 5.24 )], |
82
|
|
|
|
|
|
|
signatures => [qw( ---- ---- ---- ---- ---- 5.20 5.22 5.24 )], |
83
|
|
|
|
|
|
|
smartmatch => [qw( ---- ---- ---- ---- 5.18 5.20 5.22 5.24 )], |
84
|
|
|
|
|
|
|
); ## use tidy |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# ############################################################################## |
87
|
|
|
|
|
|
|
# # Function | Imports all features of a given of the current version of Perl # |
88
|
|
|
|
|
|
|
# # | and the pragma 'strict' and 'warnings' and the modules English # |
89
|
|
|
|
|
|
|
# # | IO::File and IO::Handle. # |
90
|
|
|
|
|
|
|
# # ----------+------------+-------------------------------------------------- # |
91
|
|
|
|
|
|
|
# # Parameter | Str | Perl version and/or to remove features (optional) # |
92
|
|
|
|
|
|
|
# # ----------+------------+-------------------------------------------------- # |
93
|
|
|
|
|
|
|
# # Result | none # |
94
|
|
|
|
|
|
|
# ############################################################################## |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub import { |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
## no critic qw{RequireUseOfExceptions} |
99
|
1
|
|
|
1
|
|
15
|
my ( $class, @extra_parameters ) = @ARG; |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
1
|
my ( $actual_perl_version, $use_perl_version, $version_tag, $version_idx ); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# --- Remove control for Perl version of parameters - if any ---------------- |
104
|
1
|
|
|
|
|
1
|
my @version = grep {/^\d[.]\d\d/smx} @extra_parameters; |
|
0
|
|
|
|
|
0
|
|
105
|
1
|
|
|
|
|
2
|
@extra_parameters = grep { not /^\d[.]\d\d/smx } @extra_parameters; |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# --- Remove Control for 'English' of parameters - if any ------------------- |
108
|
1
|
|
|
|
|
1
|
my $english_parameter = grep {/^(?:[+]?)match_vars$/smx} @extra_parameters; |
|
0
|
|
|
|
|
0
|
|
109
|
1
|
|
|
|
|
1
|
@extra_parameters = grep { not /^(?:[+]?)match_vars$/smx } @extra_parameters; |
|
0
|
|
|
|
|
0
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# --- Determine current version of Perl ------------------------------------- |
112
|
1
|
50
|
|
|
|
31
|
if ( $PERL_VERSION =~ /^v5[.](\d\d).+$/smx ) { |
113
|
1
|
|
|
|
|
2
|
$actual_perl_version = "5.$1"; |
114
|
1
|
|
|
|
|
1
|
$use_perl_version = "5.0$1"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
0
|
|
|
|
|
0
|
confess "Version '$PERL_VERSION' not detected\n"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# --- Check the version string and form feature tag ------------------------- |
121
|
1
|
|
33
|
|
|
6
|
my $version = $version[0] // $actual_perl_version; |
122
|
1
|
50
|
|
|
|
3
|
if ( $version =~ /^5[.](1[02468]|2[024])$/ismx ) { |
123
|
1
|
|
|
|
|
1
|
$use_perl_version = "5.0$1"; |
124
|
1
|
|
|
|
|
3
|
$version_idx = $1 / 2 - 5; |
125
|
1
|
|
|
|
|
1
|
$version_tag = ":$version"; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
else { |
128
|
0
|
|
|
|
|
0
|
confess "Version ($version) not supports\n"; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# --- Test - current version of Perl greater than or equal Feature version -- |
132
|
1
|
|
|
|
|
4
|
my $perl_version = Perl::Version->new($actual_perl_version); |
133
|
1
|
|
|
|
|
69
|
my $feature_version = Perl::Version->new($version); |
134
|
1
|
50
|
|
|
|
40
|
if ( $perl_version < $feature_version ) { |
135
|
0
|
|
|
|
|
0
|
confess "Features '$version' in '$actual_perl_version' not available\n"; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# --- Activate Perl version and import features ----------------------------- |
139
|
1
|
|
|
|
|
24
|
my $use = "use qw{$use_perl_version}"; |
140
|
1
|
50
|
|
|
|
1
|
eval {$use} or confess "Can't execute '$use'\n"; |
|
1
|
|
|
|
|
3
|
|
141
|
1
|
|
|
|
|
11
|
warnings->import; |
142
|
1
|
|
|
|
|
2
|
strict->import; |
143
|
1
|
|
|
|
|
4
|
version->import; |
144
|
1
|
|
|
|
|
96
|
feature->import($version_tag); |
145
|
1
|
|
|
|
|
4
|
mro::set_mro( scalar caller(), 'c3' ); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# --- Import additional features -------------------------------------------- |
148
|
1
|
|
|
|
|
3
|
foreach my $feature ( keys %FEATURES ) { |
149
|
15
|
100
|
|
|
|
22
|
if ( $FEATURES{$feature}->[$version_idx] eq '++++' ) { |
150
|
7
|
|
|
|
|
37
|
feature->import($feature); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# --- Off alerts for imported features -------------------------------------- |
155
|
1
|
|
|
|
|
5
|
foreach my $warning ( keys %WARNINGS ) { |
156
|
11
|
50
|
|
|
|
20
|
if ( $WARNINGS{$warning}->[$version_idx] ne '----' ) { |
157
|
11
|
|
|
|
|
82
|
warnings->unimport("experimental::$warning"); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# --- Remove Individual Features / Turn certain warnings -------------------- |
162
|
1
|
|
|
|
|
2
|
my $flag; |
163
|
1
|
|
|
|
|
2
|
foreach my $delete (@extra_parameters) { |
164
|
0
|
|
|
|
|
0
|
$flag = 0; |
165
|
0
|
|
|
|
|
0
|
$delete =~ s/^(?:[-+]?)(.+)/$1/smx; |
166
|
0
|
0
|
|
|
|
0
|
if ( exists $FEATURES{$delete} ) { |
167
|
0
|
|
|
|
|
0
|
$flag = 1; |
168
|
0
|
0
|
|
|
|
0
|
if ( $FEATURES{$delete}->[$version_idx] ne '----' ) { |
169
|
0
|
|
|
|
|
0
|
feature->unimport($delete); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
else { |
172
|
0
|
|
|
|
|
0
|
confess "Feature '$delete' in version '$version' not available\n"; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
} |
175
|
0
|
0
|
|
|
|
0
|
if ( exists $WARNINGS{$delete} ) { |
176
|
0
|
|
|
|
|
0
|
$flag = 1; |
177
|
0
|
0
|
|
|
|
0
|
if ( $WARNINGS{$delete}->[$version_idx] ne '----' ) { |
178
|
0
|
|
|
|
|
0
|
warnings->import("experimental::$delete"); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
} |
181
|
0
|
0
|
|
|
|
0
|
if ( not $flag ) { |
182
|
0
|
|
|
|
|
0
|
confess "Unknown feature/warning for delete '$delete'\n"; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# --- Import 'English' variables -------------------------------------------- |
187
|
1
|
|
|
|
|
1
|
local $Exporter::ExportLevel = 1; ## no critic qw(ProhibitPackageVars) |
188
|
1
|
50
|
|
|
|
2
|
if ($english_parameter) { ## no tidy |
189
|
0
|
|
|
|
|
0
|
*English::EXPORT = \@English::COMPLETE_EXPORT; |
190
|
0
|
|
|
|
|
0
|
my $match_vars = q{*English::MATCH = *&;} |
191
|
|
|
|
|
|
|
. q{*English::PREMATCH = *`;} |
192
|
|
|
|
|
|
|
. q{*English::POSTMATCH = *';} |
193
|
|
|
|
|
|
|
. q{1;}; ## use tidy |
194
|
0
|
0
|
|
|
|
0
|
eval {$match_vars} or confess("Can't create English match variablen\n"); |
|
0
|
|
|
|
|
0
|
|
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
else { |
197
|
1
|
|
|
|
|
2
|
*English::EXPORT = \@English::MINIMAL_EXPORT; |
198
|
|
|
|
|
|
|
} |
199
|
1
|
|
|
|
|
248
|
Exporter::import('English'); |
200
|
|
|
|
|
|
|
|
201
|
1
|
|
|
|
|
23
|
return; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
} ## end of sub import |
204
|
|
|
|
|
|
|
## use critic qw{RequireUseOfExceptions} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# ############################################################################## |
207
|
|
|
|
|
|
|
# # Function | Removes all experimental features a version of Perl. # |
208
|
|
|
|
|
|
|
# # ----------+--------------------------------------------------------------- # |
209
|
|
|
|
|
|
|
# # Parameter | none # |
210
|
|
|
|
|
|
|
# # ----------+--------------------------------------------------------------- # |
211
|
|
|
|
|
|
|
# # Result | none # |
212
|
|
|
|
|
|
|
# ############################################################################## |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub unimport { ## no critic qw(ProhibitBuiltinHomonyms) |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
0
|
|
|
warnings->unimport; |
217
|
0
|
|
|
|
|
|
strict->unimport; |
218
|
0
|
|
|
|
|
|
feature->unimport; |
219
|
|
|
|
|
|
|
|
220
|
0
|
|
|
|
|
|
return; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
} ## end of sub unimport |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# ############################################################################## |
225
|
|
|
|
|
|
|
# # E N D # |
226
|
|
|
|
|
|
|
# ############################################################################## |
227
|
|
|
|
|
|
|
1; |
228
|
|
|
|
|
|
|
__END__ |