Debian Codegraph @

lib/Devel/Loaded.pm

raw symbols SCIP
1 # Loaded.pm -- show what files were loaded
2 package Devel::Loaded;
3
4 # ABSTRACT: pmtools - Perl Module Tools
5
6 # ------ pragmas
7 use strict;
8 use warnings;
9 use File::Spec;
10
11 our $VERSION = '2.2.0';
12
13 # ----- define variable
14 my $path = undef; # current module path
15 our %Seen = (); # track whether we've seen this module before
16
17 BEGIN {
18 %Seen = %INC;
19
20 sub DB::DB { 1 }
21 }
22
23
24 END {
25 # get last part of Devel::Loaded path; handle File::Spec->canonpath() removing '.' from '.pm'
26 my $devel_loaded = File::Spec->catfile('Devel', 'Loaded.pm');
27 if ($devel_loaded =~ m/Loadedpm$/) {
28 $devel_loaded =~ s/Loadedpm$/Loaded.pm/;
29 }
30
31 # delete the matching absolute path from %INC
32 # NOTE: this will fail if you also have directories like ".../MyOwnDevel/Loaded.pm"
33 my $inc_devel_loaded = "";
34 foreach $path (keys(%INC)) {
35 if ($path =~ m/$devel_loaded$/) {
36 $inc_devel_loaded = $path;
37 last;
38 }
39 }
40 if ($inc_devel_loaded ne "") {
41 #delete $INC{$inc_devel_loaded};
42 }
43
44 for my $path (values %INC) {
45 print "$path\n" unless $Seen{$path};
46 }
47
48 }
49
50 1;
51
52 __END__
53
54 =head1 NAME
55
56 Devel::Loaded - Post-execution dump of loaded modules
57
58 =head1 SYNOPSIS
59
60 perl -MDevel::Loaded programname 2>/dev/null
61
62 =head1 DESCRIPTION
63
64 The Devel::Loaded module installs an at-exit handler to generate a dump of
65 all the module files used by a Perl program. If used in conjunction with
66 a I<perl -c>, you find those files loaded in at compile time with C<use>.
67 If you are willing to wait until after the program runs, you can get
68 them all.
69
70 =head1 EXAMPLES
71
72 This is compile-time only:
73
74 $ perl -MDevel::Loaded perldoc 2>/dev/null
75 /usr/local/devperl/lib/5.00554/Exporter.pm
76 /usr/local/devperl/lib/5.00554/strict.pm
77 /usr/local/devperl/lib/5.00554/vars.pm
78 /usr/local/devperl/lib/5.00554/i686-linux/Config.pm
79 /usr/local/devperl/lib/5.00554/Getopt/Std.pm
80
81 This will also catch run-time loads:
82
83 #!/usr/bin/perl
84 use Devel::Loaded;
85 ...
86
87 =head1 SEE ALSO
88
89 The I<plxload> and the I<pmload> programs, which use
90 this technique.
91
92 Neil Bowers has written a L<review|http://neilb.org/reviews/dependencies.html> of
93 Perl modules for getting dependency information (26 of them at the time of writing).
94
95 =head1 AUTHORS and COPYRIGHTS
96
97 Copyright (C) 1999 Tom Christiansen.
98
99 Copyright (C) 2006-2014, 2018 Mark Leighton Fisher.
100
101 =head1 LICENSE
102
103 This is free software; you can redistribute it and/or modify it
104 under the terms of either:
105 (a) the GNU General Public License as published by the Free
106 Software Foundation; either version 1, or (at your option) any
107 later version, or
108 (b) the Perl "Artistic License".
109 (This is the Perl 5 licensing scheme.)
110
111 Please note this is a change from the
112 original pmtools-1.00 (still available on CPAN),
113 as pmtools-1.00 were licensed only under the
114 Perl "Artistic License".