File Coverage

blib/lib/perl5i/2/RequireMessage.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package perl5i::2::RequireMessage;
2 101     101   429 use strict;
  101         152  
  101         3090  
3 101     101   375 use warnings;
  101         133  
  101         20196  
4              
5             # This is the sub that displays the message
6             my $diesub = sub {
7             my ( $sub, $mod ) = @_;
8              
9             my $hints = (caller(0))[10];
10             return unless $hints->{perl5i};
11             die( <<EOT );
12             Can't locate $mod in your Perl library. You may need to install it
13             from CPAN or another repository. Your library paths are:
14             @{[ map { " $_\n" } grep { !ref($_) } @INC ]}
15             EOT
16             };
17              
18             # This sub makes sure the die sub is always at the end of @INC.
19             push @INC => sub {
20             return if ref($INC[-1]) && $INC[-1] == $diesub;
21             @INC = grep { !(ref($_) && $_ == $diesub) } @INC;
22             push @INC => $diesub;
23             };
24             push @INC => $diesub;
25              
26             1;