← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:42 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/File/ShareDir.pm
StatementsExecuted 149 statements in 1.97ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.62ms1.85msFile::ShareDir::::BEGIN@114File::ShareDir::BEGIN@114
21171µs361µsFile::ShareDir::::_module_dir_newFile::ShareDir::_module_dir_new
11160µs60µsFile::ShareDir::::BEGIN@108File::ShareDir::BEGIN@108
21154µs258µsFile::ShareDir::::_module_dir_oldFile::ShareDir::_module_dir_old
142144µs44µsFile::ShareDir::::CORE:ftdirFile::ShareDir::CORE:ftdir (opcode)
22136µs953µsFile::ShareDir::::module_fileFile::ShareDir::module_file
42131µs165µsFile::ShareDir::::_MODULEFile::ShareDir::_MODULE
21121µs690µsFile::ShareDir::::module_dirFile::ShareDir::module_dir
11119µs19µsFile::ShareDir::::BEGIN@117File::ShareDir::BEGIN@117
21118µs33µsFile::ShareDir::::_FILEFile::ShareDir::_FILE
21115µs15µsFile::ShareDir::::CORE:regcompFile::ShareDir::CORE:regcomp (opcode)
41114µs25µsFile::ShareDir::::_CLASSFile::ShareDir::_CLASS
62114µs14µsFile::ShareDir::::CORE:matchFile::ShareDir::CORE:match (opcode)
11112µs65µsFile::ShareDir::::BEGIN@133File::ShareDir::BEGIN@133
11111µs15µsFile::ShareDir::::BEGIN@109File::ShareDir::BEGIN@109
11111µs22µsFile::ShareDir::::BEGIN@443File::ShareDir::BEGIN@443
42110µs10µsFile::ShareDir::::CORE:ftereadFile::ShareDir::CORE:fteread (opcode)
2119µs13µsFile::ShareDir::::_module_subdirFile::ShareDir::_module_subdir
2118µs8µsFile::ShareDir::::CORE:ftisFile::ShareDir::CORE:ftis (opcode)
1117µs62µsFile::ShareDir::::BEGIN@116File::ShareDir::BEGIN@116
2114µs4µsFile::ShareDir::::CORE:substFile::ShareDir::CORE:subst (opcode)
1114µs4µsFile::ShareDir::::BEGIN@110File::ShareDir::BEGIN@110
1114µs4µsFile::ShareDir::::BEGIN@111File::ShareDir::BEGIN@111
1114µs4µsFile::ShareDir::::BEGIN@112File::ShareDir::BEGIN@112
1114µs4µsFile::ShareDir::::BEGIN@113File::ShareDir::BEGIN@113
0000s0sFile::ShareDir::::_DISTFile::ShareDir::_DIST
0000s0sFile::ShareDir::::_dist_dir_newFile::ShareDir::_dist_dir_new
0000s0sFile::ShareDir::::_dist_dir_oldFile::ShareDir::_dist_dir_old
0000s0sFile::ShareDir::::_dist_file_newFile::ShareDir::_dist_file_new
0000s0sFile::ShareDir::::_dist_file_oldFile::ShareDir::_dist_file_old
0000s0sFile::ShareDir::::_dist_packfileFile::ShareDir::_dist_packfile
0000s0sFile::ShareDir::::class_fileFile::ShareDir::class_file
0000s0sFile::ShareDir::::dist_dirFile::ShareDir::dist_dir
0000s0sFile::ShareDir::::dist_fileFile::ShareDir::dist_file
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::ShareDir;
2
3=pod
4
5=head1 NAME
6
7File::ShareDir - Locate per-dist and per-module shared files
8
9=head1 SYNOPSIS
10
11 use File::ShareDir ':ALL';
12
13 # Where are distribution-level shared data files kept
14 $dir = dist_dir('File-ShareDir');
15
16 # Where are module-level shared data files kept
17 $dir = module_dir('File::ShareDir');
18
19 # Find a specific file in our dist/module shared dir
20 $file = dist_file( 'File-ShareDir', 'file/name.txt');
21 $file = module_file('File::ShareDir', 'file/name.txt');
22
23 # Like module_file, but search up the inheritance tree
24 $file = class_file( 'Foo::Bar', 'file/name.txt' );
25
26=head1 DESCRIPTION
27
28The intent of L<File::ShareDir> is to provide a companion to
29L<Class::Inspector> and L<File::HomeDir>, modules that take a
30process that is well-known by advanced Perl developers but gets a
31little tricky, and make it more available to the larger Perl community.
32
33Quite often you want or need your Perl module (CPAN or otherwise)
34to have access to a large amount of read-only data that is stored
35on the file-system at run-time.
36
37On a linux-like system, this would be in a place such as /usr/share,
38however Perl runs on a wide variety of different systems, and so
39the use of any one location is unreliable.
40
41Perl provides a little-known method for doing this, but almost
42nobody is aware that it exists. As a result, module authors often
43go through some very strange ways to make the data available to
44their code.
45
46The most common of these is to dump the data out to an enormous
47Perl data structure and save it into the module itself. The
48result are enormous multi-megabyte .pm files that chew up a
49lot of memory needlessly.
50
51Another method is to put the data "file" after the __DATA__ compiler
52tag and limit yourself to access as a filehandle.
53
54The problem to solve is really quite simple.
55
56 1. Write the data files to the system at install time.
57
58 2. Know where you put them at run-time.
59
60Perl's install system creates an "auto" directory for both
61every distribution and for every module file.
62
63These are used by a couple of different auto-loading systems
64to store code fragments generated at install time, and various
65other modules written by the Perl "ancient masters".
66
67But the same mechanism is available to any dist or module to
68store any sort of data.
69
70=head2 Using Data in your Module
71
72C<File::ShareDir> forms one half of a two part solution.
73
74Once the files have been installed to the correct directory,
75you can use C<File::ShareDir> to find your files again after
76the installation.
77
78For the installation half of the solution, see L<Module::Install>
79and its C<install_share> directive.
80
81=head1 FUNCTIONS
82
83C<File::ShareDir> provides four functions for locating files and
84directories.
85
86For greater maintainability, none of these are exported by default
87and you are expected to name the ones you want at use-time, or provide
88the C<':ALL'> tag. All of the following are equivalent.
89
90 # Load but don't import, and then call directly
91 use File::ShareDir;
92 $dir = File::ShareDir::dist_dir('My-Dist');
93
94 # Import a single function
95 use File::ShareDir 'dist_dir';
96 dist_dir('My-Dist');
97
98 # Import all the functions
99 use File::ShareDir ':ALL';
100 dist_dir('My-Dist');
101
102All of the functions will check for you that the dir/file actually
103exists, and that you have read permissions, or they will throw an
104exception.
105
106=cut
107
108369µs160µs
# spent 60µs within File::ShareDir::BEGIN@108 which was called: # once (60µs+0s) by Tapper::Config::BEGIN@17 at line 108
use 5.005;
# spent 60µs making 1 call to File::ShareDir::BEGIN@108
109321µs219µs
# spent 15µs (11+4) within File::ShareDir::BEGIN@109 which was called: # once (11µs+4µs) by Tapper::Config::BEGIN@17 at line 109
use strict;
# spent 15µs making 1 call to File::ShareDir::BEGIN@109 # spent 4µs making 1 call to strict::import
110315µs14µs
# spent 4µs within File::ShareDir::BEGIN@110 which was called: # once (4µs+0s) by Tapper::Config::BEGIN@17 at line 110
use Carp ();
# spent 4µs making 1 call to File::ShareDir::BEGIN@110
111315µs14µs
# spent 4µs within File::ShareDir::BEGIN@111 which was called: # once (4µs+0s) by Tapper::Config::BEGIN@17 at line 111
use Config ();
# spent 4µs making 1 call to File::ShareDir::BEGIN@111
112314µs14µs
# spent 4µs within File::ShareDir::BEGIN@112 which was called: # once (4µs+0s) by Tapper::Config::BEGIN@17 at line 112
use Exporter ();
# spent 4µs making 1 call to File::ShareDir::BEGIN@112
113314µs14µs
# spent 4µs within File::ShareDir::BEGIN@113 which was called: # once (4µs+0s) by Tapper::Config::BEGIN@17 at line 113
use File::Spec ();
# spent 4µs making 1 call to File::ShareDir::BEGIN@113
1143104µs11.85ms
# spent 1.85ms (1.62+233µs) within File::ShareDir::BEGIN@114 which was called: # once (1.62ms+233µs) by Tapper::Config::BEGIN@17 at line 114
use Class::Inspector ();
# spent 1.85ms making 1 call to File::ShareDir::BEGIN@114
115
116351µs2118µs
# spent 62µs (7+56) within File::ShareDir::BEGIN@116 which was called: # once (7µs+56µs) by Tapper::Config::BEGIN@17 at line 116
use vars qw{ $VERSION @ISA @EXPORT_OK %EXPORT_TAGS };
# spent 62µs making 1 call to File::ShareDir::BEGIN@116 # spent 56µs making 1 call to vars::import
117
# spent 19µs within File::ShareDir::BEGIN@117 which was called: # once (19µs+0s) by Tapper::Config::BEGIN@17 at line 131
BEGIN {
1181500ns $VERSION = '1.03';
119110µs @ISA = qw{ Exporter };
12012µs @EXPORT_OK = qw{
121 dist_dir
122 dist_file
123 module_dir
124 module_file
125 class_dir
126 class_file
127 };
12817µs %EXPORT_TAGS = (
129 ALL => [ @EXPORT_OK ],
130 );
131124µs119µs}
# spent 19µs making 1 call to File::ShareDir::BEGIN@117
132
1333834µs2119µs
# spent 65µs (12+54) within File::ShareDir::BEGIN@133 which was called: # once (12µs+54µs) by Tapper::Config::BEGIN@17 at line 133
use constant IS_MACOS => !! ($^O eq 'MacOS');
# spent 65µs making 1 call to File::ShareDir::BEGIN@133 # spent 54µs making 1 call to constant::import
134
- -
139#####################################################################
140# Interface Functions
141
142=pod
143
144=head2 dist_dir
145
146 # Get a distribution's shared files directory
147 my $dir = dist_dir('My-Distribution');
148
149The C<dist_dir> function takes a single parameter of the name of an
150installed (CPAN or otherwise) distribution, and locates the shared
151data directory created at install time for it.
152
153Returns the directory path as a string, or dies if it cannot be
154located or is not readable.
155
156=cut
157
158sub dist_dir {
159 my $dist = _DIST(shift);
160 my $dir;
161
162 # Try the new version
163 $dir = _dist_dir_new( $dist );
164 return $dir if defined $dir;
165
166 # Fall back to the legacy version
167 $dir = _dist_dir_old( $dist );
168 return $dir if defined $dir;
169
170 # Ran out of options
171 Carp::croak("Failed to find share dir for dist '$dist'");
172}
173
174sub _dist_dir_new {
175 my $dist = shift;
176
177 # Create the subpath
178 my $path = File::Spec->catdir(
179 'auto', 'share', 'dist', $dist,
180 );
181
182 # Find the full dir withing @INC
183 foreach my $inc ( @INC ) {
184 next unless defined $inc and ! ref $inc;
185 my $dir = File::Spec->catdir( $inc, $path );
186 next unless -d $dir;
187 unless ( -r $dir ) {
188 Carp::croak("Found directory '$dir', but no read permissions");
189 }
190 return $dir;
191 }
192
193 return undef;
194}
195
196sub _dist_dir_old {
197 my $dist = shift;
198
199 # Create the subpath
200 my $path = File::Spec->catdir(
201 'auto', split( /-/, $dist ),
202 );
203
204 # Find the full dir within @INC
205 foreach my $inc ( @INC ) {
206 next unless defined $inc and ! ref $inc;
207 my $dir = File::Spec->catdir( $inc, $path );
208 next unless -d $dir;
209 unless ( -r $dir ) {
210 Carp::croak("Found directory '$dir', but no read permissions");
211 }
212 return $dir;
213 }
214
215 return undef;
216}
217
218=pod
219
220=head2 module_dir
221
222 # Get a module's shared files directory
223 my $dir = module_dir('My::Module');
224
225The C<module_dir> function takes a single parameter of the name of an
226installed (CPAN or otherwise) module, and locates the shared data
227directory created at install time for it.
228
229In order to find the directory, the module B<must> be loaded when
230calling this function.
231
232Returns the directory path as a string, or dies if it cannot be
233located or is not readable.
234
235=cut
236
237
# spent 690µs (21+669) within File::ShareDir::module_dir which was called 2 times, avg 345µs/call: # 2 times (21µs+669µs) by File::ShareDir::module_file at line 391, avg 345µs/call
sub module_dir {
23823µs251µs my $module = _MODULE(shift);
# spent 51µs making 2 calls to File::ShareDir::_MODULE, avg 25µs/call
2392600ns my $dir;
240
241 # Try the new version
24223µs2361µs $dir = _module_dir_new( $module );
# spent 361µs making 2 calls to File::ShareDir::_module_dir_new, avg 180µs/call
2432500ns return $dir if defined $dir;
244
245 # Fall back to the legacy version
24627µs2258µs return _module_dir_old( $module );
# spent 258µs making 2 calls to File::ShareDir::_module_dir_old, avg 129µs/call
247}
248
249
# spent 361µs (71+290) within File::ShareDir::_module_dir_new which was called 2 times, avg 180µs/call: # 2 times (71µs+290µs) by File::ShareDir::module_dir at line 242, avg 180µs/call
sub _module_dir_new {
2502800ns my $module = shift;
251
252 # Create the subpath
253210µs475µs my $path = File::Spec->catdir(
# spent 62µs making 2 calls to File::Spec::Unix::catdir, avg 31µs/call # spent 13µs making 2 calls to File::ShareDir::_module_subdir, avg 7µs/call
254 'auto', 'share', 'module',
255 _module_subdir( $module ),
256 );
257
258 # Find the full dir withing @INC
25926µs foreach my $inc ( @INC ) {
260123µs next unless defined $inc and ! ref $inc;
2611216µs12180µs my $dir = File::Spec->catdir( $inc, $path );
# spent 180µs making 12 calls to File::Spec::Unix::catdir, avg 15µs/call
2621257µs1235µs next unless -d $dir;
# spent 35µs making 12 calls to File::ShareDir::CORE:ftdir, avg 3µs/call
263 unless ( -r $dir ) {
264 Carp::croak("Found directory '$dir', but no read permissions");
265 }
266 return $dir;
267 }
268
26925µs return undef;
270}
271
272
# spent 258µs (54+204) within File::ShareDir::_module_dir_old which was called 2 times, avg 129µs/call: # 2 times (54µs+204µs) by File::ShareDir::module_dir at line 246, avg 129µs/call
sub _module_dir_old {
27321µs my $module = shift;
27424µs2102µs my $short = Class::Inspector->filename($module);
# spent 102µs making 2 calls to Class::Inspector::filename, avg 51µs/call
27524µs236µs my $long = Class::Inspector->loaded_filename($module);
# spent 36µs making 2 calls to Class::Inspector::loaded_filename, avg 18µs/call
2762400ns $short =~ tr{/}{:} if IS_MACOS;
27722µs substr( $short, -3, 3, '' );
278233µs418µs $long =~ m/^(.*)\Q$short\E\.pm\z/s or die("Failed to find base dir");
# spent 15µs making 2 calls to File::ShareDir::CORE:regcomp, avg 7µs/call # spent 3µs making 2 calls to File::ShareDir::CORE:match, avg 2µs/call
27927µs234µs my $dir = File::Spec->catdir( "$1", 'auto', $short );
# spent 34µs making 2 calls to File::Spec::Unix::catdir, avg 17µs/call
280212µs28µs unless ( -d $dir ) {
# spent 8µs making 2 calls to File::ShareDir::CORE:ftdir, avg 4µs/call
281 Carp::croak("Directory '$dir', does not exist");
282 }
283211µs26µs unless ( -r $dir ) {
# spent 6µs making 2 calls to File::ShareDir::CORE:fteread, avg 3µs/call
284 Carp::croak("Directory '$dir', no read permissions");
285 }
28626µs return $dir;
287}
288
289=pod
290
291=head2 dist_file
292
293 # Find a file in our distribution shared dir
294 my $dir = dist_file('My-Distribution', 'file/name.txt');
295
296The C<dist_file> function takes two params of the distribution name
297and file name, locates the dist dir, and then finds the file within
298it, verifying that the file actually exists, and that it is readable.
299
300The filename should be a relative path in the format of your local
301filesystem. It will simply added to the directory using L<File::Spec>'s
302C<catfile> method.
303
304Returns the file path as a string, or dies if the file or the dist's
305directory cannot be located, or the file is not readable.
306
307=cut
308
309sub dist_file {
310 my $dist = _DIST(shift);
311 my $file = _FILE(shift);
312
313 # Try the new version first
314 my $path = _dist_file_new( $dist, $file );
315 return $path if defined $path;
316
317 # Hand off to the legacy version
318 return _dist_file_old( $dist, $file );;
319}
320
321sub _dist_file_new {
322 my $dist = shift;
323 my $file = shift;
324
325 # If it exists, what should the path be
326 my $dir = _dist_dir_new( $dist );
327 my $path = File::Spec->catfile( $dir, $file );
328
329 # Does the file exist
330 return undef unless -e $path;
331 unless ( -f $path ) {
332 Carp::croak("Found dist_file '$path', but not a file");
333 }
334 unless ( -r $path ) {
335 Carp::croak("File '$path', no read permissions");
336 }
337
338 return $path;
339}
340
341sub _dist_file_old {
342 my $dist = shift;
343 my $file = shift;
344
345 # Create the subpath
346 my $path = File::Spec->catfile(
347 'auto', split( /-/, $dist ), $file,
348 );
349
350 # Find the full dir withing @INC
351 foreach my $inc ( @INC ) {
352 next unless defined $inc and ! ref $inc;
353 my $full = File::Spec->catdir( $inc, $path );
354 next unless -e $full;
355 unless ( -r $full ) {
356 Carp::croak("Directory '$full', no read permissions");
357 }
358 return $full;
359 }
360
361 # Couldn't find it
362 Carp::croak("Failed to find shared file '$file' for dist '$dist'");
363}
364
365=pod
366
367=head2 module_file
368
369 # Find a file in our module shared dir
370 my $dir = module_file('My::Module', 'file/name.txt');
371
372The C<module_file> function takes two params of the module name
373and file name. It locates the module dir, and then finds the file within
374it, verifying that the file actually exists, and that it is readable.
375
376In order to find the directory, the module B<must> be loaded when
377calling this function.
378
379The filename should be a relative path in the format of your local
380filesystem. It will simply added to the directory using L<File::Spec>'s
381C<catfile> method.
382
383Returns the file path as a string, or dies if the file or the dist's
384directory cannot be located, or the file is not readable.
385
386=cut
387
388
# spent 953µs (36+917) within File::ShareDir::module_file which was called 2 times, avg 477µs/call: # once (21µs+536µs) by Tapper::Config::_switch_context at line 71 of Tapper/Config.pm # once (15µs+381µs) by Tapper::Config::_prepare_special_entries at line 82 of Tapper/Config.pm
sub module_file {
38925µs2114µs my $module = _MODULE(shift);
# spent 114µs making 2 calls to File::ShareDir::_MODULE, avg 57µs/call
39024µs233µs my $file = _FILE(shift);
# spent 33µs making 2 calls to File::ShareDir::_FILE, avg 17µs/call
39124µs2690µs my $dir = module_dir($module);
# spent 690µs making 2 calls to File::ShareDir::module_dir, avg 345µs/call
39224µs266µs my $path = File::Spec->catfile($dir, $file);
# spent 66µs making 2 calls to File::Spec::Unix::catfile, avg 33µs/call
393214µs28µs unless ( -e $path ) {
# spent 8µs making 2 calls to File::ShareDir::CORE:ftis, avg 4µs/call
394 Carp::croak("File '$file' does not exist in module dir");
395 }
39629µs25µs unless ( -r $path ) {
# spent 5µs making 2 calls to File::ShareDir::CORE:fteread, avg 2µs/call
397 Carp::croak("File '$file' cannot be read, no read permissions");
398 }
39927µs $path;
400}
401
402=pod
403
404=head2 class_file
405
406 # Find a file in our module shared dir, or in our parent class
407 my $dir = class_file('My::Module', 'file/name.txt');
408
409The C<module_file> function takes two params of the module name
410and file name. It locates the module dir, and then finds the file within
411it, verifying that the file actually exists, and that it is readable.
412
413In order to find the directory, the module B<must> be loaded when
414calling this function.
415
416The filename should be a relative path in the format of your local
417filesystem. It will simply added to the directory using L<File::Spec>'s
418C<catfile> method.
419
420If the file is NOT found for that module, C<class_file> will scan up
421the module's @ISA tree, looking for the file in all of the parent
422classes.
423
424This allows you to, in effect, "subclass" shared files.
425
426Returns the file path as a string, or dies if the file or the dist's
427directory cannot be located, or the file is not readable.
428
429=cut
430
431sub class_file {
432 my $module = _MODULE(shift);
433 my $file = _FILE(shift);
434
435 # Get the super path ( not including UNIVERSAL )
436 # Rather than using Class::ISA, we'll use an inlined version
437 # that implements the same basic algorithm.
438 my @path = ();
439 my @queue = ( $module );
440 my %seen = ( $module => 1 );
441 while ( my $cl = shift @queue ) {
442 push @path, $cl;
4433456µs233µs
# spent 22µs (11+11) within File::ShareDir::BEGIN@443 which was called: # once (11µs+11µs) by Tapper::Config::BEGIN@17 at line 443
no strict 'refs';
# spent 22µs making 1 call to File::ShareDir::BEGIN@443 # spent 11µs making 1 call to strict::unimport
444 unshift @queue, grep { ! $seen{$_}++ }
445 map { s/^::/main::/; s/\'/::/g; $_ }
446 ( @{"${cl}::ISA"} );
447 }
448
449 # Search up the path
450 foreach my $class ( @path ) {
451 local $@;
452 my $dir = eval {
453 module_dir($class);
454 };
455 next if $@;
456 my $path = File::Spec->catfile($dir, $file);
457 unless ( -e $path ) {
458 next;
459 }
460 unless ( -r $path ) {
461 Carp::croak("File '$file' cannot be read, no read permissions");
462 }
463 return $path;
464 }
465 Carp::croak("File '$file' does not exist in class or parent shared files");
466}
467
- -
471#####################################################################
472# Support Functions
473
474
# spent 13µs (9+4) within File::ShareDir::_module_subdir which was called 2 times, avg 7µs/call: # 2 times (9µs+4µs) by File::ShareDir::_module_dir_new at line 253, avg 7µs/call
sub _module_subdir {
47521µs my $module = shift;
476210µs24µs $module =~ s/::/-/g;
# spent 4µs making 2 calls to File::ShareDir::CORE:subst, avg 2µs/call
47726µs return $module;
478}
479
480sub _dist_packfile {
481 my $module = shift;
482 my @dirs = grep { -e } ( $Config::Config{archlibexp}, $Config::Config{sitearchexp} );
483 my $file = File::Spec->catfile(
484 'auto', split( /::/, $module), '.packlist',
485 );
486
487 foreach my $dir ( @dirs ) {
488 my $path = File::Spec->catfile( $dir, $file );
489 next unless -f $path;
490
491 # Load the file
492 my $packlist = ExtUtils::Packlist->new($path);
493 unless ( $packlist ) {
494 die "Failed to load .packlist file for $module";
495 }
496
497 die "CODE INCOMPLETE";
498 }
499
500 die "CODE INCOMPLETE";
501}
502
503# Inlined from Params::Util pure perl version
504
# spent 25µs (14+11) within File::ShareDir::_CLASS which was called 4 times, avg 6µs/call: # 4 times (14µs+11µs) by File::ShareDir::_MODULE at line 525, avg 6µs/call
sub _CLASS {
505433µs411µs (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef;
# spent 11µs making 4 calls to File::ShareDir::CORE:match, avg 3µs/call
506}
507
508
509# Maintainer note: The following private functions are used by
510# File::ShareDir::PAR. (It has to or else it would have to copy&fork)
511# So if you significantly change or even remove them, please
512# notify the File::ShareDir::PAR maintainer(s). Thank you!
513
514# Matches a valid distribution name
515### This is a total guess at this point
516sub _DIST {
517 if ( defined $_[0] and ! ref $_[0] and $_[0] =~ /^[a-z0-9+_-]+$/is ) {
518 return shift;
519 }
520 Carp::croak("Not a valid distribution name");
521}
522
523# A valid and loaded module name
524
# spent 165µs (31+134) within File::ShareDir::_MODULE which was called 4 times, avg 41µs/call: # 2 times (23µs+92µs) by File::ShareDir::module_file at line 389, avg 57µs/call # 2 times (8µs+43µs) by File::ShareDir::module_dir at line 238, avg 25µs/call
sub _MODULE {
52546µs425µs my $module = _CLASS(shift) or Carp::croak("Not a valid module name");
# spent 25µs making 4 calls to File::ShareDir::_CLASS, avg 6µs/call
526420µs4109µs if ( Class::Inspector->loaded($module) ) {
# spent 109µs making 4 calls to Class::Inspector::loaded, avg 27µs/call
527 return $module;
528 }
529 Carp::croak("Module '$module' is not loaded");
530}
531
532# A valid file name
533
# spent 33µs (18+16) within File::ShareDir::_FILE which was called 2 times, avg 17µs/call: # 2 times (18µs+16µs) by File::ShareDir::module_file at line 390, avg 17µs/call
sub _FILE {
5342900ns my $file = shift;
53522µs unless ( defined $file and ! ref $file and length $file ) {
536 Carp::croak("Did not pass a file name");
537 }
538211µs216µs if ( File::Spec->file_name_is_absolute($file) ) {
# spent 16µs making 2 calls to File::Spec::Unix::file_name_is_absolute, avg 8µs/call
539 Carp::croak("Cannot use absolute file name '$file'");
540 }
54125µs $file;
542}
543
54413µs1;
545
546=pod
547
548=head1 SUPPORT
549
550Bugs should always be submitted via the CPAN bug tracker
551
552L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-ShareDir>
553
554For other issues, contact the maintainer.
555
556=head1 AUTHOR
557
558Adam Kennedy E<lt>adamk@cpan.orgE<gt>
559
560=head1 SEE ALSO
561
562L<File::HomeDir>, L<Module::Install>, L<Module::Install::Share>,
563L<File::ShareDir::PAR>
564
565=head1 COPYRIGHT
566
567Copyright 2005 - 2011 Adam Kennedy.
568
569This program is free software; you can redistribute
570it and/or modify it under the same terms as Perl itself.
571
572The full text of the license can be found in the
573LICENSE file included with this module.
574
575=cut
 
# spent 44µs within File::ShareDir::CORE:ftdir which was called 14 times, avg 3µs/call: # 12 times (35µs+0s) by File::ShareDir::_module_dir_new at line 262, avg 3µs/call # 2 times (8µs+0s) by File::ShareDir::_module_dir_old at line 280, avg 4µs/call
sub File::ShareDir::CORE:ftdir; # opcode
# spent 10µs within File::ShareDir::CORE:fteread which was called 4 times, avg 3µs/call: # 2 times (6µs+0s) by File::ShareDir::_module_dir_old at line 283, avg 3µs/call # 2 times (5µs+0s) by File::ShareDir::module_file at line 396, avg 2µs/call
sub File::ShareDir::CORE:fteread; # opcode
# spent 8µs within File::ShareDir::CORE:ftis which was called 2 times, avg 4µs/call: # 2 times (8µs+0s) by File::ShareDir::module_file at line 393, avg 4µs/call
sub File::ShareDir::CORE:ftis; # opcode
# spent 14µs within File::ShareDir::CORE:match which was called 6 times, avg 2µs/call: # 4 times (11µs+0s) by File::ShareDir::_CLASS at line 505, avg 3µs/call # 2 times (3µs+0s) by File::ShareDir::_module_dir_old at line 278, avg 2µs/call
sub File::ShareDir::CORE:match; # opcode
# spent 15µs within File::ShareDir::CORE:regcomp which was called 2 times, avg 7µs/call: # 2 times (15µs+0s) by File::ShareDir::_module_dir_old at line 278, avg 7µs/call
sub File::ShareDir::CORE:regcomp; # opcode
# spent 4µs within File::ShareDir::CORE:subst which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by File::ShareDir::_module_subdir at line 476, avg 2µs/call
sub File::ShareDir::CORE:subst; # opcode