← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:17 2013

Filename/usr/lib64/perl5/5.16.0/FindBin.pm
StatementsExecuted 38 statements in 6.01ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11118.5ms79.9msFindBin::::BEGIN@83FindBin::BEGIN@83
11110.9ms11.9msFindBin::::BEGIN@85FindBin::BEGIN@85
1117.79ms9.02msFindBin::::BEGIN@84FindBin::BEGIN@84
111339µs1.28msFindBin::::initFindBin::init
11181µs331µsFindBin::::BEGIN@80FindBin::BEGIN@80
11170µs93µsFindBin::::cwd2FindBin::cwd2
11146µs1.33msFindBin::::BEGIN@166FindBin::BEGIN@166
11126µs26µsFindBin::::CORE:ftfileFindBin::CORE:ftfile (opcode)
11126µs26µsFindBin::::CORE:readlinkFindBin::CORE:readlink (opcode)
Call graph for these subroutines as a Graphviz dot language file.
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
9FindBin - Locate directory of original perl script
10
11=head1 SYNOPSIS
12
13 use FindBin;
14 use lib "$FindBin::Bin/../lib";
15
16 or
17
18 use FindBin qw($Bin);
19 use lib "$Bin/../lib";
20
21=head1 DESCRIPTION
22
23Locates the full path to the script bin directory to allow the use
24of paths relative to the bin directory.
25
26This allows a user to setup a directory tree for some software with
27directories C<< <root>/bin >> and C<< <root>/lib >>, and then the above
28example will allow the use of modules in the lib directory without knowing
29where the software tree is installed.
30
31If perl is invoked using the B<-e> option or the perl script is read from
32C<STDIN> then FindBin sets both C<$Bin> and C<$RealBin> to the current
33directory.
34
35=head1 EXPORTABLE VARIABLES
36
37 $Bin - path to bin directory from where script was invoked
38 $Script - basename of script from which perl was invoked
39 $RealBin - $Bin with all links resolved
40 $RealScript - $Script with all links resolved
41
42=head1 KNOWN ISSUES
43
44If there are two modules using C<FindBin> from different directories
45under the same interpreter, this won't work. Since C<FindBin> uses a
46C<BEGIN> block, it'll be executed only once, and only the first caller
47will get it right. This is a problem under mod_perl and other persistent
48Perl environments, where you shouldn't use this module. Which also means
49that you should avoid using C<FindBin> in modules that you plan to put
50on CPAN. To make sure that C<FindBin> will work is to call the C<again>
51function:
52
53 use FindBin;
54 FindBin::again(); # or FindBin->again;
55
56In former versions of FindBin there was no C<again> function. The
57workaround was to force the C<BEGIN> block to be executed again:
58
59 delete $INC{'FindBin.pm'};
60 require FindBin;
61
62=head1 AUTHORS
63
64FindBin is supported as part of the core perl distribution. Please send bug
65reports to E<lt>F<perlbug@perl.org>E<gt> using the perlbug program
66included with perl.
67
68Graham Barr E<lt>F<gbarr@pobox.com>E<gt>
69Nick Ing-Simmons E<lt>F<nik@tiuk.ti.com>E<gt>
70
71=head1 COPYRIGHT
72
73Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
74This program is free software; you can redistribute it and/or modify it
75under the same terms as Perl itself.
76
77=cut
78
79package FindBin;
802269µs2582µs
# spent 331µs (81+250) within FindBin::BEGIN@80 which was called: # once (81µs+250µs) by main::BEGIN@16 at line 80
use Carp;
# spent 331µs making 1 call to FindBin::BEGIN@80 # spent 250µs making 1 call to Exporter::import
81168µsrequire 5.000;
8213µsrequire Exporter;
832895µs280.3ms
# spent 79.9ms (18.5+61.4) within FindBin::BEGIN@83 which was called: # once (18.5ms+61.4ms) by main::BEGIN@16 at line 83
use Cwd qw(getcwd cwd abs_path);
# spent 79.9ms making 1 call to FindBin::BEGIN@83 # spent 459µs making 1 call to Exporter::import
8421.03ms29.29ms
# spent 9.02ms (7.79+1.23) within FindBin::BEGIN@84 which was called: # once (7.79ms+1.23ms) by main::BEGIN@16 at line 84
use File::Basename;
# spent 9.02ms making 1 call to FindBin::BEGIN@84 # spent 271µs making 1 call to Exporter::import
8522.87ms111.9ms
# spent 11.9ms (10.9+976µs) within FindBin::BEGIN@85 which was called: # once (10.9ms+976µs) by main::BEGIN@16 at line 85
use File::Spec;
# spent 11.9ms making 1 call to FindBin::BEGIN@85
86
87112µs@EXPORT_OK = qw($Bin $Script $RealBin $RealScript $Dir $RealDir);
88115µs%EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]);
89131µs@ISA = qw(Exporter);
90
9113µs$VERSION = "1.51";
92
93
94# needed for VMS-specific filename translation
9515µsif( $^O eq 'VMS' ) {
96 require VMS::Filespec;
97 VMS::Filespec->import;
98}
99
100
# spent 93µs (70+23) within FindBin::cwd2 which was called: # once (70µs+23µs) by FindBin::init at line 137
sub cwd2 {
101181µs123µs my $cwd = getcwd();
# spent 23µs making 1 call to Cwd::getcwd
102 # getcwd might fail if it hasn't access to the current directory.
103 # try harder.
10412µs defined $cwd or $cwd = cwd();
105131µs $cwd;
106}
107
108sub init
109
# spent 1.28ms (339µs+944µs) within FindBin::init which was called: # once (339µs+944µs) by FindBin::BEGIN@166 at line 166
{
11016µs *Dir = \$Bin;
11112µs *RealDir = \$RealBin;
112
113128µs if($0 eq '-e' || $0 eq '-')
114 {
115 # perl invoked with -e or script is on C<STDIN>
116 $Script = $RealScript = $0;
117 $Bin = $RealBin = cwd2();
118 $Bin = VMS::Filespec::unixify($Bin) if $^O eq 'VMS';
119 }
120 else
121 {
12216µs my $script = $0;
123
12416µs if ($^O eq 'VMS')
125 {
126 ($Bin,$Script) = VMS::Filespec::rmsexpand($0) =~ /(.*[\]>\/]+)(.*)/s;
127 # C<use disk:[dev]/lib> isn't going to work, so unixify first
128 ($Bin = VMS::Filespec::unixify($Bin)) =~ s/\/\z//;
129 ($RealBin,$RealScript) = ($Bin,$Script);
130 }
131 else
132 {
133163µs126µs croak("Cannot find current script '$0'") unless(-f $script);
# spent 26µs making 1 call to FindBin::CORE:ftfile
134
135 # Ensure $script contains the complete path in case we C<chdir>
136
137171µs3605µs $script = File::Spec->catfile(cwd2(), $script)
# spent 442µs making 1 call to File::Spec::Unix::catfile # spent 93µs making 1 call to FindBin::cwd2 # spent 70µs making 1 call to File::Spec::Unix::file_name_is_absolute
138 unless File::Spec->file_name_is_absolute($script);
139
140118µs1115µs ($Script,$Bin) = fileparse($script);
# spent 115µs making 1 call to File::Basename::fileparse
141
142 # Resolve $script if it is a link
14312µs while(1)
144 {
145153µs126µs my $linktext = readlink($script);
# spent 26µs making 1 call to FindBin::CORE:readlink
146
147116µs177µs ($RealScript,$RealBin) = fileparse($script);
# spent 77µs making 1 call to File::Basename::fileparse
14814µs last unless defined $linktext;
149
150 $script = (File::Spec->file_name_is_absolute($linktext))
151 ? $linktext
152 : File::Spec->catfile($RealBin, $linktext);
153 }
154
155 # Get absolute paths to directories
15612µs if ($Bin) {
15713µs my $BinOld = $Bin;
158183µs156µs $Bin = abs_path($Bin);
# spent 56µs making 1 call to Cwd::abs_path
15912µs defined $Bin or $Bin = File::Spec->canonpath($BinOld);
160 }
161160µs140µs $RealBin = abs_path($RealBin) if($RealBin);
# spent 40µs making 1 call to Cwd::abs_path
162 }
163 }
164}
165
1661232µs22.61ms
# spent 1.33ms (46µs+1.28) within FindBin::BEGIN@166 which was called: # once (46µs+1.28ms) by main::BEGIN@16 at line 166
BEGIN { init }
# spent 1.33ms making 1 call to FindBin::BEGIN@166 # spent 1.28ms making 1 call to FindBin::init
167
16819µs*again = \&init;
169
170138µs1; # Keep require happy
 
# spent 26µs within FindBin::CORE:ftfile which was called: # once (26µs+0s) by FindBin::init at line 133
sub FindBin::CORE:ftfile; # opcode
# spent 26µs within FindBin::CORE:readlink which was called: # once (26µs+0s) by FindBin::init at line 145
sub FindBin::CORE:readlink; # opcode