| 1 | # vi: set ts=4 sw=4 ht=4 et : | ||||||||||||||||||||||||||||
| 2 | package perl5i::1; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Module::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use perl5i::1::DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Want; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use perl5i::1::Meta; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Encode (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use perl5i::1::autobox; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use perl5i::VERSION; our $VERSION = perl5i::VERSION->VERSION; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | our $Latest = 'perl5i::1'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # This works around their lexical nature. | ||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use parent 'autodie'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use parent 'perl5i::1::autobox'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use parent 'autovivification'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use parent 'utf8'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use parent 'open'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||
| 31 | sub import { | ||||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=7.8
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | require File::stat; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | require Modern::Perl; | |||||||||||||||||||||||||||
| 37 | 1 | Modern::Perl->import; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | my $caller = caller; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Modern::Perl won't pass this through to our caller. | ||||||||||||||||||||||||||||
| 42 | 1 | require mro; | |||||||||||||||||||||||||||
| 43 | 1 | mro::set_mro( $caller, 'c3' ); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | load_in_caller( $caller => ( | |||||||||||||||||||||||||||
| 46 | ["CLASS"], ["File::chdir"], | ||||||||||||||||||||||||||||
| 47 | [English => qw(-no_match_vars)], | ||||||||||||||||||||||||||||
| 48 | ["Want" => qw(want)], ["Try::Tiny"], ["Perl6::Caller"], ["Carp"] | ||||||||||||||||||||||||||||
| 49 | ) ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Have to call both or it won't work. | ||||||||||||||||||||||||||||
| 52 | 1 | perl5i::1::autobox::import($class); | |||||||||||||||||||||||||||
| 53 | 1 | autovivification::unimport($class); | |||||||||||||||||||||||||||
| 54 | 1 | utf8::import($class); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | open::import($class, ":encoding(utf8)"); | |||||||||||||||||||||||||||
| 57 | 1 | open::import($class, ":std"); | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Export our gmtime() and localtime() | ||||||||||||||||||||||||||||
| 60 | 1 | (\&{$Latest .'::DateTime::dt_gmtime'})->alias($caller, 'gmtime'); | |||||||||||||||||||||||||||
| 61 | 1 | (\&{$Latest .'::DateTime::dt_localtime'})->alias($caller, 'localtime'); | |||||||||||||||||||||||||||
| 62 | 1 | (\&{$Latest .'::DateTime::dt_time'})->alias($caller, 'time'); | |||||||||||||||||||||||||||
| 63 | 1 | (\&stat)->alias( $caller, 'stat' ); | |||||||||||||||||||||||||||
| 64 | 1 | (\&lstat)->alias( $caller, 'lstat' ); | |||||||||||||||||||||||||||
| 65 | 1 | (\&utf8_open)->alias($caller, 'open'); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | # fix die so that it always returns 255 | ||||||||||||||||||||||||||||
| 68 | *CORE::GLOBAL::die = sub { | ||||||||||||||||||||||||||||
| 69 | # Leave a single ref be | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | local $! = 255; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return CORE::die(@_) if @_ == 1 and ref $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ == 1 and ref $_[0]
MC/DC0%0/2
@_ == 1 and ref $_[0]
@_ == 1
ref $_[0]
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | my $error = join '', @_; | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | unless ($error =~ /\n$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | my ($file, $line) = (caller)[1,2]; | |||||||||||||||||||||||||||
| 76 | 0 | $error .= " at $file line $line.\n"; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | local $! = 255; | |||||||||||||||||||||||||||
| 80 | 0 | return CORE::die($error); | |||||||||||||||||||||||||||
| 81 | 1 | }; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # utf8ify @ARGV | ||||||||||||||||||||||||||||
| 85 | 1 | $_ = Encode::decode('utf8', $_) for @ARGV; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | $^H{perl5i} = 1; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # autodie needs a bit more convincing | ||||||||||||||||||||||||||||
| 91 | 1 | @_ = ( $class, ":all" ); | |||||||||||||||||||||||||||
| 92 | 1 | goto &autodie::import; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub unimport { $^H{perl5i} = 0 } | ||||||||||||||||||||||||||
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | sub utf8_open(*;$@) { ## no critic (Subroutines::ProhibitSubroutinePrototypes) | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | my $ret; | ||||||||||||||||||||||||||
|
Subroutine
utf8_open: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if( @_ == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | $ret = CORE::open $_[0]; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | else { | ||||||||||||||||||||||||||||
| 103 | 0 | $ret = CORE::open $_[0], $_[1], @_[2..$#_]; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | # Don't try to binmode an unopened filehandle | ||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $ret unless $ret; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | my $h = (caller 1)[10]; | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | binmode $_[0], ":encoding(utf8)" if $h->{perl5i}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | return $ret; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub load_in_caller { | ||||||||||||||||||||||||||||
| 116 | 1 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||
|
Subroutine
load_in_caller: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | 1 | my @modules = @_; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 1 | for my $spec (@modules) { | |||||||||||||||||||||||||||
| 120 | 7 | my( $module, @args ) = @$spec; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 7 | load($module); | |||||||||||||||||||||||||||
| 123 | ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||
| 124 | 7 | ▶ | eval qq{ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | package $caller; | ||||||||||||||||||||||||||||
| 126 | \$module->import(\@args); | ||||||||||||||||||||||||||||
| 127 | 1; | ||||||||||||||||||||||||||||
| 128 | } or die "Error while perl5i loaded $module => @args: $@"; | ||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 1 | return; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | # File::stat does not play nice in list context | ||||||||||||||||||||||||||||
| 136 | sub stat { | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | return CORE::stat(@_) if wantarray; | ||||||||||||||||||||||||||
|
Subroutine
stat: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | return File::stat::stat(@_); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | sub lstat { | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return CORE::lstat(@_) if wantarray; | ||||||||||||||||||||||||||
|
Subroutine
lstat: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | return File::stat::lstat(@_); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 1 | 1; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||