blib/lib/perlrc.pm

filter: Statementstmt 91.4% 32 / 35 Branchbran 50.0% 8 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 80.3% 45 / 56 CC 11 SCAR 18.6
CC
11
Cov
78%
import
9.5
_home
4.2
BEGIN
1.0
CRAP 6.4
↑ Summary
1 package perlrc;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶sub _home {
Subroutine _home: called CC=4 SCAR=14.5
10 1 my $user = shift;
11 1 ▶ my $uid = (length $user ? getpwnam($user) : $>);
Branch: 1 branch
BranchTrueFalseTotal
length $user ? : 0 1 1
12 1 ▶ defined $uid or return "~$user";
Branch: 1 branch
BranchTrueFalseTotal
defined $uid or return "~$user" 1 0 1
13 1 my $home = (getpwuid $uid)[7];
14 1 ▶ defined $home or return "~$user";
Branch: 1 branch
BranchTrueFalseTotal
defined $home or return "~$user" 1 0 1
15 1 $home
16 }
17  
18 1 ▶sub import {
Subroutine import: called CC=8 SCAR=22.5
19 1 shift;
20 1 my $path;
21 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 1 1
22 0 $path = join(',', @_);
23 }
24 else {
25 1 $path = '~/.perlrc:/etc/perlrc';
26 }
27  
28 1 my @path = split /:/, $path;
29 1 for my $file (@path) {
30 2 $file =~ s/^~([^\/]*)/_home($1)/e;
31 2 ▶ $file = '.' unless length $file;
Branch: 1 branch
BranchTrueFalseTotal
unless length $file 0 2 2
32 2 ▶ $file =~ s/\/*$/\/.perlrc/ if -d $file;
Branch: 1 branch
BranchTrueFalseTotal
if -d $file 0 2 2
33 2 my @files = $file;
34 2 ▶ push @files, "$file.pl" unless $file =~ /\.pl$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /\.pl$/ 2 0 2
35 2 for (@files) {
36 4 ▶ if (-f $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $_) 0 4 4
37 package main;
38 0 do $_;
39 0 return;
40 }
41 }
42 }
43 1 warn "no perlrc file found in $path\n";
44 }
45  
46 1 1;
47 __END__
↑ Summary