| 1 | package Modern::Perl; | ||||||||||||||||||||
| 2 | # ABSTRACT: enable all of the features of Modern Perl with one import | ||||||||||||||||||||
| 3 | 5 | $Modern::Perl::VERSION = '1.20220515'; | |||||||||||||||||||
| 4 | 5 | ▶ | use 5.010_000; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 5 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 5 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 5 | ▶ | use mro (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 5 | ▶ | use feature (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # enable methods on filehandles; unnecessary when 5.14 autoloads them | ||||||||||||||||||||
| 13 | 5 | ▶ | use IO::File (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 5 | ▶ | use IO::Handle (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 5 | my $wanted_date; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | sub VERSION { | ||||||||||||||||||||
| 19 | 2 | ▶ | my ($self, $version) = @_; | ||||||||||||||||||
|
Subroutine
VERSION: called CC=6 SCAR=22.7
Pod
undocumented
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 2 | ▶ | return $Modern::Perl::VERSION || 2022 unless defined $version; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$Modern::Perl::VERSION || 2022
MC/DC0%0/1
$Modern::Perl::VERSION || 2022
$Modern::Perl::VERSION
Truth table0%0/2
A
A= $Modern::Perl::VERSION
| |||||||||||||||||||||
| 22 | 2 | ▶ | return $Modern::Perl::VERSION || 2022 if $version < 2009; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$Modern::Perl::VERSION || 2022
MC/DC0%0/1
$Modern::Perl::VERSION || 2022
$Modern::Perl::VERSION
Truth table0%0/2
A
A= $Modern::Perl::VERSION
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | ▶ | $wanted_date = $version if (caller(1))[3] =~ /::BEGIN/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | 2 | return 2022; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub import { | ||||||||||||||||||||
| 29 | 12 | ▶ | my ($class, $date) = @_; | ||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.2
| |||||||||||||||||||||
| 30 | 12 | ▶ | $date = $wanted_date unless defined $date; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 12 | my $feature_tag = validate_date( $date ); | |||||||||||||||||||
| 33 | 11 | undef $wanted_date; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 11 | warnings->import; | |||||||||||||||||||
| 36 | 11 | strict->import; | |||||||||||||||||||
| 37 | 11 | feature->import( $feature_tag ); | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 11 | ▶ | if ($feature_tag ge ':5.34') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 0 | feature->import( 'signatures' ); | |||||||||||||||||||
| 41 | 0 | warnings->unimport( 'experimental::signatures' ); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 11 | mro::set_mro( scalar caller(), 'c3' ); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub unimport { | ||||||||||||||||||||
| 48 | 1 | ▶ | warnings->unimport; | ||||||||||||||||||
|
Subroutine
unimport: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 49 | 1 | strict->unimport; | |||||||||||||||||||
| 50 | 1 | feature->unimport; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | sub validate_date { | ||||||||||||||||||||
| 54 | 12 | ▶ | my %dates = ( | ||||||||||||||||||
|
Subroutine
validate_date: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 55 | 2009 => ':5.10', | ||||||||||||||||||||
| 56 | 2010 => ':5.10', | ||||||||||||||||||||
| 57 | 2011 => ':5.12', | ||||||||||||||||||||
| 58 | 2012 => ':5.14', | ||||||||||||||||||||
| 59 | 2013 => ':5.16', | ||||||||||||||||||||
| 60 | 2014 => ':5.18', | ||||||||||||||||||||
| 61 | 2015 => ':5.20', | ||||||||||||||||||||
| 62 | 2016 => ':5.24', | ||||||||||||||||||||
| 63 | 2017 => ':5.24', | ||||||||||||||||||||
| 64 | 2018 => ':5.26', | ||||||||||||||||||||
| 65 | 2019 => ':5.28', | ||||||||||||||||||||
| 66 | 2020 => ':5.30', | ||||||||||||||||||||
| 67 | 2021 => ':5.32', | ||||||||||||||||||||
| 68 | 2022 => ':5.34', | ||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 12 | my $date = shift; | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | # always enable unicode_strings when available | ||||||||||||||||||||
| 74 | 12 | ▶ | unless ($date) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 7 | ▶ | return ':5.12' if $] > 5.011003; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 76 | 0 | return ':5.10'; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 5 | my $year = substr $date, 0, 4; | |||||||||||||||||||
| 80 | 5 | ▶ | return $dates{$year} if exists $dates{$year}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 1 | die "Unknown date '$date' requested\n"; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 5 | 1; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||||