Filename | /usr/share/perl/5.10/FindBin.pm |
Statements | Executed 41 statements in 1.20ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 90µs | 260µs | init | FindBin::
1 | 1 | 1 | 36µs | 132µs | BEGIN@95 | FindBin::
1 | 1 | 1 | 24µs | 128µs | BEGIN@99 | FindBin::
2 | 2 | 1 | 19µs | 19µs | CORE:ftfile (opcode) | FindBin::
1 | 1 | 1 | 17µs | 68µs | BEGIN@98 | FindBin::
1 | 1 | 1 | 14µs | 14µs | BEGIN@100 | FindBin::
1 | 1 | 1 | 13µs | 13µs | CORE:readlink (opcode) | FindBin::
1 | 1 | 1 | 9µs | 269µs | BEGIN@205 | FindBin::
1 | 1 | 1 | 4µs | 4µs | CORE:match (opcode) | FindBin::
0 | 0 | 0 | 0s | 0s | cwd2 | FindBin::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # FindBin.pm | ||||
2 | # | ||||
3 | # Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. | ||||
4 | # This program is free software; you can redistribute it and/or modify it | ||||
5 | # under the same terms as Perl itself. | ||||
6 | |||||
7 | =head1 NAME | ||||
8 | |||||
- - | |||||
94 | package FindBin; | ||||
95 | 3 | 97µs | 2 | 228µs | # spent 132µs (36+96) within FindBin::BEGIN@95 which was called:
# once (36µs+96µs) by C4::Auth_with_cas::BEGIN@28 at line 95 # spent 132µs making 1 call to FindBin::BEGIN@95
# spent 96µs making 1 call to Exporter::import |
96 | 1 | 18µs | require 5.000; | ||
97 | 1 | 1µs | require Exporter; | ||
98 | 3 | 51µs | 2 | 120µs | # spent 68µs (17+52) within FindBin::BEGIN@98 which was called:
# once (17µs+52µs) by C4::Auth_with_cas::BEGIN@28 at line 98 # spent 68µs making 1 call to FindBin::BEGIN@98
# spent 52µs making 1 call to Exporter::import |
99 | 3 | 54µs | 2 | 233µs | # spent 128µs (24+105) within FindBin::BEGIN@99 which was called:
# once (24µs+105µs) by C4::Auth_with_cas::BEGIN@28 at line 99 # spent 128µs making 1 call to FindBin::BEGIN@99
# spent 104µs making 1 call to Exporter::import |
100 | 3 | 755µs | 1 | 14µs | # spent 14µs within FindBin::BEGIN@100 which was called:
# once (14µs+0s) by C4::Auth_with_cas::BEGIN@28 at line 100 # spent 14µs making 1 call to FindBin::BEGIN@100 |
101 | |||||
102 | 1 | 2µs | @EXPORT_OK = qw($Bin $Script $RealBin $RealScript $Dir $RealDir); | ||
103 | 1 | 4µs | %EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); | ||
104 | 1 | 10µs | @ISA = qw(Exporter); | ||
105 | |||||
106 | 1 | 400ns | $VERSION = "1.50"; | ||
107 | |||||
108 | |||||
109 | # needed for VMS-specific filename translation | ||||
110 | 1 | 1µs | if( $^O eq 'VMS' ) { | ||
111 | require VMS::Filespec; | ||||
112 | VMS::Filespec->import; | ||||
113 | } | ||||
114 | |||||
115 | sub cwd2 { | ||||
116 | my $cwd = getcwd(); | ||||
117 | # getcwd might fail if it hasn't access to the current directory. | ||||
118 | # try harder. | ||||
119 | defined $cwd or $cwd = cwd(); | ||||
120 | $cwd; | ||||
121 | } | ||||
122 | |||||
123 | sub init | ||||
124 | # spent 260µs (90+170) within FindBin::init which was called:
# once (90µs+170µs) by FindBin::BEGIN@205 at line 205 | ||||
125 | 1 | 1µs | *Dir = \$Bin; | ||
126 | 1 | 400ns | *RealDir = \$RealBin; | ||
127 | |||||
128 | 1 | 5µs | if($0 eq '-e' || $0 eq '-') | ||
129 | { | ||||
130 | # perl invoked with -e or script is on C<STDIN> | ||||
131 | $Script = $RealScript = $0; | ||||
132 | $Bin = $RealBin = cwd2(); | ||||
133 | $Bin = VMS::Filespec::unixify($Bin) if $^O eq 'VMS'; | ||||
134 | } | ||||
135 | else | ||||
136 | { | ||||
137 | 1 | 1µs | my $script = $0; | ||
138 | |||||
139 | 1 | 2µs | if ($^O eq 'VMS') | ||
140 | { | ||||
141 | ($Bin,$Script) = VMS::Filespec::rmsexpand($0) =~ /(.*[\]>\/]+)(.*)/s; | ||||
142 | # C<use disk:[dev]/lib> isn't going to work, so unixify first | ||||
143 | ($Bin = VMS::Filespec::unixify($Bin)) =~ s/\/\z//; | ||||
144 | ($RealBin,$RealScript) = ($Bin,$Script); | ||||
145 | } | ||||
146 | else | ||||
147 | { | ||||
148 | 1 | 2µs | my $dosish = ($^O eq 'MSWin32' or $^O eq 'os2'); | ||
149 | 1 | 39µs | 2 | 17µs | unless(($script =~ m#/# || ($dosish && $script =~ m#\\#)) # spent 14µs making 1 call to FindBin::CORE:ftfile
# spent 4µs making 1 call to FindBin::CORE:match |
150 | && -f $script) | ||||
151 | { | ||||
152 | my $dir; | ||||
153 | foreach $dir (File::Spec->path) | ||||
154 | { | ||||
155 | my $scr = File::Spec->catfile($dir, $script); | ||||
156 | |||||
157 | # $script can been found via PATH but perl could have | ||||
158 | # been invoked as 'perl file'. Do a dumb check to see | ||||
159 | # if $script is a perl program, if not then keep $script = $0 | ||||
160 | # | ||||
161 | # well we actually only check that it is an ASCII file | ||||
162 | # we know its executable so it is probably a script | ||||
163 | # of some sort. | ||||
164 | if(-f $scr && -r _ && ($dosish || -x _) && -s _ && -T _) | ||||
165 | { | ||||
166 | $script = $scr; | ||||
167 | last; | ||||
168 | } | ||||
169 | } | ||||
170 | } | ||||
171 | |||||
172 | 1 | 12µs | 1 | 5µs | croak("Cannot find current script '$0'") unless(-f $script); # spent 5µs making 1 call to FindBin::CORE:ftfile |
173 | |||||
174 | # Ensure $script contains the complete path in case we C<chdir> | ||||
175 | |||||
176 | 1 | 14µs | 1 | 25µs | $script = File::Spec->catfile(cwd2(), $script) # spent 25µs making 1 call to File::Spec::Unix::file_name_is_absolute |
177 | unless File::Spec->file_name_is_absolute($script); | ||||
178 | |||||
179 | 1 | 5µs | 1 | 55µs | ($Script,$Bin) = fileparse($script); # spent 55µs making 1 call to File::Basename::fileparse |
180 | |||||
181 | # Resolve $script if it is a link | ||||
182 | 1 | 500ns | while(1) | ||
183 | { | ||||
184 | 1 | 19µs | 1 | 13µs | my $linktext = readlink($script); # spent 13µs making 1 call to FindBin::CORE:readlink |
185 | |||||
186 | 1 | 3µs | 1 | 19µs | ($RealScript,$RealBin) = fileparse($script); # spent 19µs making 1 call to File::Basename::fileparse |
187 | 1 | 2µs | last unless defined $linktext; | ||
188 | |||||
189 | $script = (File::Spec->file_name_is_absolute($linktext)) | ||||
190 | ? $linktext | ||||
191 | : File::Spec->catfile($RealBin, $linktext); | ||||
192 | } | ||||
193 | |||||
194 | # Get absolute paths to directories | ||||
195 | 1 | 500ns | if ($Bin) { | ||
196 | 1 | 500ns | my $BinOld = $Bin; | ||
197 | 1 | 36µs | 1 | 30µs | $Bin = abs_path($Bin); # spent 30µs making 1 call to Cwd::abs_path |
198 | 1 | 500ns | defined $Bin or $Bin = File::Spec->canonpath($BinOld); | ||
199 | } | ||||
200 | 1 | 10µs | 1 | 7µs | $RealBin = abs_path($RealBin) if($RealBin); # spent 7µs making 1 call to Cwd::abs_path |
201 | } | ||||
202 | } | ||||
203 | } | ||||
204 | |||||
205 | 1 | 45µs | 2 | 528µs | # spent 269µs (9+260) within FindBin::BEGIN@205 which was called:
# once (9µs+260µs) by C4::Auth_with_cas::BEGIN@28 at line 205 # spent 269µs making 1 call to FindBin::BEGIN@205
# spent 260µs making 1 call to FindBin::init |
206 | |||||
207 | 1 | 2µs | *again = \&init; | ||
208 | |||||
209 | 1 | 9µs | 1; # Keep require happy | ||
sub FindBin::CORE:ftfile; # opcode | |||||
# spent 4µs within FindBin::CORE:match which was called:
# once (4µs+0s) by FindBin::init at line 149 | |||||
# spent 13µs within FindBin::CORE:readlink which was called:
# once (13µs+0s) by FindBin::init at line 184 |