line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ##############################################################################
|
2
|
|
|
|
|
|
|
# # Script : Perl::Modern::Perl #
|
3
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- #
|
4
|
|
|
|
|
|
|
# # Copyright : Frei unter GNU General Public License bzw. Artistic License #
|
5
|
|
|
|
|
|
|
# # Authors : JVBSOFT - Jürgen von Brietzke 0.001 - 1.005 #
|
6
|
|
|
|
|
|
|
# # Version : 1.005 19.Dez.2015 #
|
7
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- #
|
8
|
|
|
|
|
|
|
# # Function : Lädt alle Features der aktuellen benutzten Perl-Version. #
|
9
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- #
|
10
|
|
|
|
|
|
|
# # Language : PERL 5 (V) 5.12.xx - 5.22.xx #
|
11
|
|
|
|
|
|
|
# # Coding : ISO 8859-15 / Latin-9 UNIX-Zeilenende #
|
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
|
|
|
|
|
|
|
# # ------------------------------------------------------------- #
|
19
|
|
|
|
|
|
|
# # Perl::Version ActivePerl-REPO-Module #
|
20
|
|
|
|
|
|
|
# ##############################################################################
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Perl::Modern::Perl 1.005;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# ##############################################################################
|
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
31335
|
use 5.012;
|
|
2
|
|
|
|
|
8
|
|
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
11
|
use feature ();
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
31
|
|
29
|
2
|
|
|
2
|
|
1544
|
use mro ();
|
|
2
|
|
|
|
|
24507
|
|
|
2
|
|
|
|
|
106
|
|
30
|
2
|
|
|
2
|
|
22
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
66
|
|
31
|
2
|
|
|
2
|
|
2354
|
use version;
|
|
2
|
|
|
|
|
5946
|
|
|
2
|
|
|
|
|
19
|
|
32
|
2
|
|
|
2
|
|
226
|
use warnings;
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
81
|
|
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
13
|
use Carp;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
215
|
|
35
|
2
|
|
|
2
|
|
2257
|
use English qw{-no_match_vars};
|
|
2
|
|
|
|
|
10025
|
|
|
2
|
|
|
|
|
11
|
|
36
|
2
|
|
|
2
|
|
2575
|
use Perl::Version;
|
|
2
|
|
|
|
|
8348
|
|
|
2
|
|
|
|
|
1953
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# ##############################################################################
|
39
|
|
|
|
|
|
|
# # Feature/Warnings-Table : Enthaelt alle verfuegbaren Features bis Perl 5.22 #
|
40
|
|
|
|
|
|
|
# # -------------------------------------------------------------------------- #
|
41
|
|
|
|
|
|
|
# # 5.xx <-> Feature ist im Feature-Tag enthalten ( ':5.xx' ) #
|
42
|
|
|
|
|
|
|
# # ++++ <-> Feature ist in der Perl-Version zuschaltbar #
|
43
|
|
|
|
|
|
|
# # ---- <-> Feature ist in der Perl-Version nicht implementiert #
|
44
|
|
|
|
|
|
|
# ##############################################################################
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our %FEATURES = (
|
47
|
|
|
|
|
|
|
# ------ Perl-Version ----- 5.10 5.12 5.14 5.16 5.18 5.20 5.22 -----------------
|
48
|
|
|
|
|
|
|
array_base => [ qw( 5.10 5.12 5.14 ++++ ++++ ++++ ++++ ) ],
|
49
|
|
|
|
|
|
|
bitwise => [ qw( ---- ---- ---- ---- ---- ---- ++++ ) ],
|
50
|
|
|
|
|
|
|
current_sub => [ qw( ---- ---- ---- 5.16 5.18 5.20 5.22 ) ],
|
51
|
|
|
|
|
|
|
evalbytes => [ qw( ---- ---- ---- 5.16 5.18 5.20 5.22 ) ],
|
52
|
|
|
|
|
|
|
fc => [ qw( ---- ---- ---- 5.16 5.18 5.20 5.22 ) ],
|
53
|
|
|
|
|
|
|
lexical_subs => [ qw( ---- ---- ---- ---- ++++ ++++ ++++ ) ],
|
54
|
|
|
|
|
|
|
postderef => [ qw( ---- ---- ---- ---- ---- ++++ ++++ ) ],
|
55
|
|
|
|
|
|
|
postderef_qq => [ qw( ---- ---- ---- ---- ---- ++++ ++++ ) ],
|
56
|
|
|
|
|
|
|
refaliasing => [ qw( ---- ---- ---- ---- ---- ---- ++++ ) ],
|
57
|
|
|
|
|
|
|
say => [ qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 ) ],
|
58
|
|
|
|
|
|
|
signatures => [ qw( ---- ---- ---- ---- ---- ++++ ++++ ) ],
|
59
|
|
|
|
|
|
|
state => [ qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 ) ],
|
60
|
|
|
|
|
|
|
switch => [ qw( 5.10 5.12 5.14 5.16 5.18 5.20 5.22 ) ],
|
61
|
|
|
|
|
|
|
unicode_eval => [ qw( ---- ---- ---- 5.16 5.18 5.20 5.22 ) ],
|
62
|
|
|
|
|
|
|
unicode_strings => [ qw( ---- 5.12 5.14 5.16 5.18 5.20 5.22 ) ],
|
63
|
|
|
|
|
|
|
);
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
our %WARNINGS = (
|
66
|
|
|
|
|
|
|
# ----- Perl-Version ------ 5.10 5.12 5.14 5.16 5.18 5.20 5.22 -----------------
|
67
|
|
|
|
|
|
|
autoderef => [ qw( ---- ---- ---- ---- ---- 5.20 5.22 ) ],
|
68
|
|
|
|
|
|
|
bitwise => [ qw( ---- ---- ---- ---- ---- ---- 5.22 ) ],
|
69
|
|
|
|
|
|
|
const_attr => [ qw( ---- ---- ---- ---- ---- ---- 5.22 ) ],
|
70
|
|
|
|
|
|
|
lexical_subs => [ qw( ---- ---- ---- ---- 5.18 5.20 5.22 ) ],
|
71
|
|
|
|
|
|
|
lexical_topic => [ qw( ---- ---- ---- ---- 5.18 5.20 5.22 ) ],
|
72
|
|
|
|
|
|
|
postderef => [ qw( ---- ---- ---- ---- ---- 5.20 5.22 ) ],
|
73
|
|
|
|
|
|
|
re_strict => [ qw( ---- ---- ---- ---- ---- ---- 5.22 ) ],
|
74
|
|
|
|
|
|
|
refaliasing => [ qw( ---- ---- ---- ---- ---- ---- 5.22 ) ],
|
75
|
|
|
|
|
|
|
regex_sets => [ qw( ---- ---- ---- ---- 5.18 5.20 5.22 ) ],
|
76
|
|
|
|
|
|
|
signatures => [ qw( ---- ---- ---- ---- ---- 5.20 5.22 ) ],
|
77
|
|
|
|
|
|
|
smartmatch => [ qw( ---- ---- ---- ---- 5.18 5.20 5.22 ) ],
|
78
|
|
|
|
|
|
|
);
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# ##############################################################################
|
81
|
|
|
|
|
|
|
# # Aufgabe | Importiert die experimentellen Features einer Perl-Version. #
|
82
|
|
|
|
|
|
|
# # ----------+ -------------------------------------------------------------- #
|
83
|
|
|
|
|
|
|
# # Aufruf | use Perl::Features qw( [ 5.22 [ say [ -state ... ] ] ] ); #
|
84
|
|
|
|
|
|
|
# # | -------------------------------------------------------------- #
|
85
|
|
|
|
|
|
|
# # | Importiert alle Featurs von Perl 5.22 ausser 'say' und 'state. #
|
86
|
|
|
|
|
|
|
# # ----------+--------------------------------------------------------------- #
|
87
|
|
|
|
|
|
|
# # Rückgabe | keine #
|
88
|
|
|
|
|
|
|
# ##############################################################################
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub import {
|
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
1
|
|
12
|
my ( $class, $version, @delete_features_or_warnings ) = @ARG;
|
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
2
|
my ( $actual_perl_version, $use_perl_version, $version_tag, $version_idx );
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# --- Aktuelle PERL-Version bestimmen und Feature-Tag bilden ----------------
|
97
|
1
|
50
|
|
|
|
44
|
if ( $PERL_VERSION =~ /^v5[.](\d\d).+$/smx ) {
|
98
|
1
|
|
|
|
|
4
|
$actual_perl_version = "5.$1";
|
99
|
1
|
|
|
|
|
2
|
$use_perl_version = "5.0$1";
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
else {
|
102
|
0
|
|
|
|
|
0
|
confess "Version '$PERL_VERSION' not detected\n";
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# --- Versions-String pruefen und Feature-Tag bilden ------------------------
|
106
|
1
|
50
|
|
|
|
5
|
if ( not $version ) {
|
107
|
1
|
|
|
|
|
2
|
$version = $actual_perl_version;
|
108
|
|
|
|
|
|
|
}
|
109
|
1
|
50
|
|
|
|
6
|
if ( $version =~ /^5[.](1[13579]|2[13])$/ismx ) {
|
110
|
0
|
|
|
|
|
0
|
confess "Developers version ($version) not supports\n";
|
111
|
|
|
|
|
|
|
}
|
112
|
1
|
50
|
|
|
|
4
|
if ( $version =~ /^5[.](1[02468]|2[02])$/ismx ) {
|
113
|
1
|
|
|
|
|
10
|
$use_perl_version = "5.0$1";
|
114
|
1
|
|
|
|
|
6
|
$version_idx = $1 / 2 - 5;
|
115
|
1
|
|
|
|
|
2
|
$version_tag = ":$version";
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
else {
|
118
|
0
|
|
|
|
|
0
|
confess "Version ($version) not supports\n";
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# --- Testen ob die aktuelle PERL-Version groesser gleich Feature-Version ---
|
122
|
1
|
|
|
|
|
4
|
my $perl_version = Perl::Version->new($actual_perl_version);
|
123
|
1
|
|
|
|
|
108
|
my $feature_version = Perl::Version->new($version);
|
124
|
1
|
50
|
|
|
|
63
|
if ( $perl_version < $feature_version ) {
|
125
|
0
|
|
|
|
|
0
|
confess "Features '$version' in '$actual_perl_version' not available\n";
|
126
|
|
|
|
|
|
|
}
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# --- PERL-Version aktivieren und Features importieren ----------------------
|
129
|
1
|
|
|
|
|
35
|
my $use = "use qw{$use_perl_version}";
|
130
|
1
|
50
|
|
|
|
2
|
eval { $use } or confess "Can't execute '$use'\n";
|
|
1
|
|
|
|
|
5
|
|
131
|
1
|
|
|
|
|
14
|
warnings->import;
|
132
|
1
|
|
|
|
|
6
|
strict->import;
|
133
|
1
|
|
|
|
|
6
|
version->import;
|
134
|
1
|
|
|
|
|
1210
|
feature->import( $version_tag );
|
135
|
1
|
|
|
|
|
5
|
mro::set_mro( scalar caller(), 'c3' );
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# --- Zusatz-Features importieren -------------------------------------------
|
138
|
1
|
|
|
|
|
5
|
foreach my $feature ( keys %FEATURES ) {
|
139
|
15
|
100
|
|
|
|
39
|
if ( $FEATURES{$feature}->[$version_idx] eq '++++' ) {
|
140
|
7
|
|
|
|
|
57
|
feature->import($feature);
|
141
|
|
|
|
|
|
|
}
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# --- Warnmeldung fuer importierte Features ausschalten ---------------------
|
145
|
1
|
|
|
|
|
5
|
foreach my $warning ( keys %WARNINGS ) {
|
146
|
11
|
50
|
|
|
|
28
|
if ( $WARNINGS{$warning}->[$version_idx] ne '----' ) {
|
147
|
11
|
|
|
|
|
107
|
warnings->unimport( "experimental::$warning" );
|
148
|
|
|
|
|
|
|
}
|
149
|
|
|
|
|
|
|
}
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# --- Einzelne Features entfernen / einzelne Warnungen einschalten ----------
|
152
|
1
|
|
|
|
|
3
|
my $flag;
|
153
|
1
|
|
|
|
|
2
|
foreach my $delete ( @delete_features_or_warnings ) {
|
154
|
0
|
|
|
|
|
0
|
$flag = 0;
|
155
|
0
|
|
|
|
|
0
|
$delete =~ s/^[-+](.+)/$1/smx;
|
156
|
0
|
0
|
|
|
|
0
|
if ( exists $FEATURES{$delete} ) {
|
157
|
0
|
|
|
|
|
0
|
$flag = 1;
|
158
|
0
|
0
|
|
|
|
0
|
if ( $FEATURES{$delete}->[$version_idx] ne '----' ) {
|
159
|
0
|
|
|
|
|
0
|
feature->unimport($delete);
|
160
|
|
|
|
|
|
|
}
|
161
|
|
|
|
|
|
|
else {
|
162
|
0
|
|
|
|
|
0
|
confess "Feature '$delete' in version '$version' not available\n"
|
163
|
|
|
|
|
|
|
}
|
164
|
|
|
|
|
|
|
}
|
165
|
0
|
0
|
|
|
|
0
|
if ( exists $WARNINGS{$delete} ) {
|
166
|
0
|
|
|
|
|
0
|
$flag = 1;
|
167
|
0
|
0
|
|
|
|
0
|
if ( $WARNINGS{$delete}->[$version_idx] ne '----' ) {
|
168
|
0
|
|
|
|
|
0
|
warnings->import( "experimental::$delete" );
|
169
|
|
|
|
|
|
|
}
|
170
|
|
|
|
|
|
|
}
|
171
|
0
|
0
|
|
|
|
0
|
if ( not $flag ) {
|
172
|
0
|
|
|
|
|
0
|
confess "Unknown feature/warning for delete '$delete'\n";
|
173
|
|
|
|
|
|
|
}
|
174
|
|
|
|
|
|
|
}
|
175
|
|
|
|
|
|
|
|
176
|
1
|
|
|
|
|
27
|
return;
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
}
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
# ##############################################################################
|
181
|
|
|
|
|
|
|
# # Aufgabe | Entfernt alle experimentellen Features einer Perl-Version. #
|
182
|
|
|
|
|
|
|
# # ----------+ -------------------------------------------------------------- #
|
183
|
|
|
|
|
|
|
# # Rückgabe | keine #
|
184
|
|
|
|
|
|
|
# ##############################################################################
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub unimport {
|
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
0
|
|
|
warnings->unimport;
|
189
|
0
|
|
|
|
|
|
strict->unimport;
|
190
|
0
|
|
|
|
|
|
feature->unimport;
|
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
return;
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
}
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# ##############################################################################
|
197
|
|
|
|
|
|
|
# # E N D E #
|
198
|
|
|
|
|
|
|
# ##############################################################################
|
199
|
|
|
|
|
|
|
1;
|
200
|
|
|
|
|
|
|
__END__
|