line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package perlrc; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
26149
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
464
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _home { |
10
|
1
|
|
|
1
|
|
3
|
my $user = shift; |
11
|
1
|
50
|
|
|
|
6
|
my $uid = (length $user ? getpwnam($user) : $>); |
12
|
1
|
50
|
|
|
|
4
|
defined $uid or return "~$user"; |
13
|
1
|
|
|
|
|
1083
|
my $home = (getpwuid $uid)[7]; |
14
|
1
|
50
|
|
|
|
7
|
defined $home or return "~$user"; |
15
|
1
|
|
|
|
|
5
|
$home |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub import { |
19
|
1
|
|
|
1
|
|
7
|
shift; |
20
|
1
|
|
|
|
|
2
|
my $path; |
21
|
1
|
50
|
|
|
|
4
|
if (@_) { |
22
|
0
|
|
|
|
|
0
|
$path = join(',', @_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
1
|
|
|
|
|
2
|
$path = '~/.perlrc:/etc/perlrc'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
5
|
my @path = split /:/, $path; |
29
|
1
|
|
|
|
|
3
|
for my $file (@path) { |
30
|
2
|
|
|
|
|
9
|
$file =~ s/^~([^\/]*)/_home($1)/e; |
|
1
|
|
|
|
|
2
|
|
31
|
2
|
50
|
|
|
|
6
|
$file = '.' unless length $file; |
32
|
2
|
50
|
|
|
|
28
|
$file =~ s/\/*$/\/.perlrc/ if -d $file; |
33
|
2
|
|
|
|
|
3
|
my @files = $file; |
34
|
2
|
50
|
|
|
|
9
|
push @files, "$file.pl" unless $file =~ /\.pl$/; |
35
|
2
|
|
|
|
|
4
|
for (@files) { |
36
|
4
|
50
|
|
|
|
53
|
if (-f $_) { |
37
|
|
|
|
|
|
|
package main; |
38
|
0
|
|
|
|
|
0
|
do $_; |
39
|
0
|
|
|
|
|
0
|
return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
1
|
|
|
|
|
44
|
warn "no perlrc file found in $path\n"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |