Filename | /usr/share/perl/5.10/FindBin.pm |
Statements | Executed 41 statements in 1.07ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 70µs | 216µs | init | FindBin::
1 | 1 | 1 | 37µs | 122µs | BEGIN@98 | FindBin::
1 | 1 | 1 | 35µs | 142µs | BEGIN@99 | FindBin::
1 | 1 | 1 | 34µs | 142µs | BEGIN@95 | FindBin::
1 | 1 | 1 | 21µs | 23µs | BEGIN@100 | FindBin::
2 | 2 | 1 | 12µs | 12µs | CORE:ftfile (opcode) | FindBin::
1 | 1 | 1 | 11µs | 11µs | CORE:readlink (opcode) | FindBin::
1 | 1 | 1 | 10µs | 227µs | BEGIN@205 | FindBin::
1 | 1 | 1 | 2µs | 2µ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 | 73µs | 2 | 250µs | # spent 142µs (34+108) within FindBin::BEGIN@95 which was called:
# once (34µs+108µs) by C4::Auth_with_cas::BEGIN@28 at line 95 # spent 142µs making 1 call to FindBin::BEGIN@95
# spent 108µs making 1 call to Exporter::import |
96 | 1 | 16µs | require 5.000; | ||
97 | 1 | 900ns | require Exporter; | ||
98 | 3 | 72µs | 2 | 207µs | # spent 122µs (37+85) within FindBin::BEGIN@98 which was called:
# once (37µs+85µs) by C4::Auth_with_cas::BEGIN@28 at line 98 # spent 122µs making 1 call to FindBin::BEGIN@98
# spent 85µs making 1 call to Exporter::import |
99 | 3 | 63µs | 2 | 248µs | # spent 142µs (35+107) within FindBin::BEGIN@99 which was called:
# once (35µs+107µs) by C4::Auth_with_cas::BEGIN@28 at line 99 # spent 142µs making 1 call to FindBin::BEGIN@99
# spent 107µs making 1 call to Exporter::import |
100 | 3 | 620µs | 2 | 25µs | # spent 23µs (21+2) within FindBin::BEGIN@100 which was called:
# once (21µs+2µs) by C4::Auth_with_cas::BEGIN@28 at line 100 # spent 23µs making 1 call to FindBin::BEGIN@100
# spent 2µs making 1 call to UNIVERSAL::import |
101 | |||||
102 | 1 | 2µs | @EXPORT_OK = qw($Bin $Script $RealBin $RealScript $Dir $RealDir); | ||
103 | 1 | 3µs | %EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); | ||
104 | 1 | 21µs | @ISA = qw(Exporter); | ||
105 | |||||
106 | 1 | 500ns | $VERSION = "1.50"; | ||
107 | |||||
108 | |||||
109 | # needed for VMS-specific filename translation | ||||
110 | 1 | 2µ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 216µs (70+146) within FindBin::init which was called:
# once (70µs+146µs) by FindBin::BEGIN@205 at line 205 | ||||
125 | 3 | 7µs | *Dir = \$Bin; | ||
126 | *RealDir = \$RealBin; | ||||
127 | |||||
128 | 2 | 2µ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 | my $script = $0; | ||||
138 | |||||
139 | 8 | 61µ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 | my $dosish = ($^O eq 'MSWin32' or $^O eq 'os2'); | ||||
149 | 2 | 12µs | unless(($script =~ m#/# || ($dosish && $script =~ m#\\#)) # spent 10µs making 1 call to FindBin::CORE:ftfile
# spent 2µ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 | 2µs | croak("Cannot find current script '$0'") unless(-f $script); # spent 2µs making 1 call to FindBin::CORE:ftfile | ||
173 | |||||
174 | # Ensure $script contains the complete path in case we C<chdir> | ||||
175 | |||||
176 | 1 | 16µs | $script = File::Spec->catfile(cwd2(), $script) # spent 16µs making 1 call to File::Spec::Unix::file_name_is_absolute | ||
177 | unless File::Spec->file_name_is_absolute($script); | ||||
178 | |||||
179 | 1 | 38µs | ($Script,$Bin) = fileparse($script); # spent 38µs making 1 call to File::Basename::fileparse | ||
180 | |||||
181 | # Resolve $script if it is a link | ||||
182 | while(1) | ||||
183 | { | ||||
184 | 3 | 21µs | 1 | 11µs | my $linktext = readlink($script); # spent 11µs making 1 call to FindBin::CORE:readlink |
185 | |||||
186 | 1 | 14µs | ($RealScript,$RealBin) = fileparse($script); # spent 14µs making 1 call to File::Basename::fileparse | ||
187 | 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 | 3 | 54µs | if ($Bin) { | ||
196 | my $BinOld = $Bin; | ||||
197 | 1 | 39µs | $Bin = abs_path($Bin); # spent 39µs making 1 call to Cwd::abs_path | ||
198 | defined $Bin or $Bin = File::Spec->canonpath($BinOld); | ||||
199 | } | ||||
200 | 1 | 13µs | $RealBin = abs_path($RealBin) if($RealBin); # spent 13µs making 1 call to Cwd::abs_path | ||
201 | } | ||||
202 | } | ||||
203 | } | ||||
204 | |||||
205 | 1 | 44µs | 2 | 443µs | # spent 227µs (10+216) within FindBin::BEGIN@205 which was called:
# once (10µs+216µs) by C4::Auth_with_cas::BEGIN@28 at line 205 # spent 227µs making 1 call to FindBin::BEGIN@205
# spent 216µ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 2µs within FindBin::CORE:match which was called:
# once (2µs+0s) by FindBin::init at line 149 | |||||
# spent 11µs within FindBin::CORE:readlink which was called:
# once (11µs+0s) by FindBin::init at line 184 |