← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/bin/epoll_server.pl
  Run on Wed Jan 5 05:34:33 2011
Reported on Wed Jan 5 05:38:42 2011

File /usr/lib/perl5/5.10.1/Module/Pluggable/Object.pm
Statements Executed 3084
Statement Execution Time 36.8ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
361111.0ms92.8msModule::Pluggable::Object::::search_pathsModule::Pluggable::Object::search_paths
361110.6ms14.6msModule::Pluggable::Object::::_requireModule::Pluggable::Object::_require
1119.99ms10.5msModule::Pluggable::Object::::BEGIN@4Module::Pluggable::Object::BEGIN@4
95214.14ms4.14msModule::Pluggable::Object::::_is_legitModule::Pluggable::Object::_is_legit
53211.86ms18.5msModule::Pluggable::Object::::handle_finding_pluginModule::Pluggable::Object::handle_finding_plugin
2501321.67ms1.67msModule::Pluggable::Object::::CORE:matchModule::Pluggable::Object::CORE:match (opcode)
3221.67ms105msModule::Pluggable::Object::::pluginsModule::Pluggable::Object::plugins
13211.55ms14.7msModule::Pluggable::Object::::handle_innerpackagesModule::Pluggable::Object::handle_innerpackages
96121.01ms1.01msModule::Pluggable::Object::::CORE:ftisModule::Pluggable::Object::CORE:ftis (opcode)
3021958µs1.26msModule::Pluggable::Object::::__ANON__[:281]Module::Pluggable::Object::__ANON__[:281]
2511835µs986µsModule::Pluggable::Object::::_is_editor_junkModule::Pluggable::Object::_is_editor_junk
111784µs1.33msModule::Pluggable::Object::::BEGIN@6Module::Pluggable::Object::BEGIN@6
311635µs93.5msModule::Pluggable::Object::::search_directoriesModule::Pluggable::Object::search_directories
6432614µs614µsModule::Pluggable::Object::::CORE:regcompModule::Pluggable::Object::CORE:regcomp (opcode)
912533µs533µsModule::Pluggable::Object::::CORE:openModule::Pluggable::Object::CORE:open (opcode)
511478µs6.45msModule::Pluggable::Object::::find_filesModule::Pluggable::Object::find_files
912326µs326µsModule::Pluggable::Object::::CORE:readlineModule::Pluggable::Object::CORE:readline (opcode)
4122281µs281µsModule::Pluggable::Object::::CORE:qrModule::Pluggable::Object::CORE:qr (opcode)
311127µs127µsModule::Pluggable::Object::::_setup_exceptionsModule::Pluggable::Object::_setup_exceptions
912126µs126µsModule::Pluggable::Object::::CORE:closeModule::Pluggable::Object::CORE:close (opcode)
32285µs85µsModule::Pluggable::Object::::newModule::Pluggable::Object::new
251248µs48µsModule::Pluggable::Object::::CORE:substModule::Pluggable::Object::CORE:subst (opcode)
11138µs98µsModule::Pluggable::Object::::BEGIN@8Module::Pluggable::Object::BEGIN@8
11130µs40µsModule::Pluggable::Object::::BEGIN@3Module::Pluggable::Object::BEGIN@3
11120µs122µsModule::Pluggable::Object::::BEGIN@5Module::Pluggable::Object::BEGIN@5
11117µs74µsModule::Pluggable::Object::::BEGIN@7Module::Pluggable::Object::BEGIN@7
11114µs50µsModule::Pluggable::Object::::BEGIN@9Module::Pluggable::Object::BEGIN@9
51210µs10µsModule::Pluggable::Object::::CORE:ftdirModule::Pluggable::Object::CORE:ftdir (opcode)
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Module::Pluggable::Object;
2
3342µs251µs
# spent 40µs (30+11) within Module::Pluggable::Object::BEGIN@3 which was called # once (30µs+11µs) by Catalyst::BEGIN@19 at line 3
use strict;
# spent 40µs making 1 call to Module::Pluggable::Object::BEGIN@3 # spent 10µs making 1 call to strict::import
43189µs110.5ms
# spent 10.5ms (9.99+493µs) within Module::Pluggable::Object::BEGIN@4 which was called # once (9.99ms+493µs) by Catalyst::BEGIN@19 at line 4
use File::Find ();
# spent 10.5ms making 1 call to Module::Pluggable::Object::BEGIN@4
5350µs2224µs
# spent 122µs (20+102) within Module::Pluggable::Object::BEGIN@5 which was called # once (20µs+102µs) by Catalyst::BEGIN@19 at line 5
use File::Basename;
# spent 122µs making 1 call to Module::Pluggable::Object::BEGIN@5 # spent 102µs making 1 call to Exporter::import
63309µs21.50ms
# spent 1.33ms (784µs+544µs) within Module::Pluggable::Object::BEGIN@6 which was called # once (784µs+544µs) by Catalyst::BEGIN@19 at line 6
use File::Spec::Functions qw(splitdir catdir curdir catfile abs2rel);
# spent 1.33ms making 1 call to Module::Pluggable::Object::BEGIN@6 # spent 168µs making 1 call to Exporter::import
7342µs2130µs
# spent 74µs (17+56) within Module::Pluggable::Object::BEGIN@7 which was called # once (17µs+56µs) by Catalyst::BEGIN@19 at line 7
use Carp qw(croak carp);
# spent 74µs making 1 call to Module::Pluggable::Object::BEGIN@7 # spent 56µs making 1 call to Exporter::import
8349µs2158µs
# spent 98µs (38+60) within Module::Pluggable::Object::BEGIN@8 which was called # once (38µs+60µs) by Catalyst::BEGIN@19 at line 8
use Devel::InnerPackage;
# spent 98µs making 1 call to Module::Pluggable::Object::BEGIN@8 # spent 60µs making 1 call to Exporter::import
933.14ms285µs
# spent 50µs (14+36) within Module::Pluggable::Object::BEGIN@9 which was called # once (14µs+36µs) by Catalyst::BEGIN@19 at line 9
use vars qw($VERSION);
# spent 50µs making 1 call to Module::Pluggable::Object::BEGIN@9 # spent 36µs making 1 call to vars::import
10
1112µs$VERSION = '3.9';
12
13
14
# spent 85µs within Module::Pluggable::Object::new which was called 3 times, avg 28µs/call: # 2 times (64µs+0s) by Config::Any::finder at line 253 of Config/Any.pm, avg 32µs/call # once (22µs+0s) by Catalyst::locate_components at line 2455 of Catalyst.pm
sub new {
159162µs my $class = shift;
16 my %opts = @_;
17
18 return bless \%opts, $class;
19
20}
21
22### Eugggh, this code smells
23### This is what happens when you keep adding patches
24### *sigh*
25
26
27
# spent 105ms (1.67+103) within Module::Pluggable::Object::plugins which was called 3 times, avg 35.0ms/call: # 2 times (1.30ms+68.4ms) by Config::Any::plugins at line 272 of Config/Any.pm, avg 34.8ms/call # once (373µs+34.8ms) by Catalyst::locate_components at line 2459 of Catalyst.pm
sub plugins {
2848502µs my $self = shift;
29
30 # override 'require'
31 $self->{'require'} = 1 if $self->{'inner'};
32
33 my $filename = $self->{'filename'};
34 my $pkg = $self->{'package'};
35
36 # Get the exception params instantiated
37 $self->_setup_exceptions;
# spent 127µs making 3 calls to Module::Pluggable::Object::_setup_exceptions, avg 42µs/call
38
39 # automatically turn a scalar search path or namespace into a arrayref
40 for (qw(search_path search_dirs)) {
41642µs $self->{$_} = [ $self->{$_} ] if exists $self->{$_} && !ref($self->{$_});
42 }
43
44 # default search path is '<Module>::<Name>::Plugin'
45 $self->{'search_path'} = ["${pkg}::Plugin"] unless $self->{'search_path'};
46
47
48 #my %opts = %$self;
49
50
51 # check to see if we're running under test
52 my @SEARCHDIR = exists $INC{"blib.pm"} && defined $filename && $filename =~ m!(^|/)blib/! ? grep {/blib/} @INC : @INC;
53
54 # add any search_dir params
55 unshift @SEARCHDIR, @{$self->{'search_dirs'}} if defined $self->{'search_dirs'};
56
57
58 my @plugins = $self->search_directories(@SEARCHDIR);
# spent 93.5ms making 3 calls to Module::Pluggable::Object::search_directories, avg 31.2ms/call
59 push(@plugins, $self->handle_innerpackages($_)) for @{$self->{'search_path'}};
# spent 7.53ms making 8 calls to Module::Pluggable::Object::handle_innerpackages, avg 941µs/call
60
61 # push @plugins, map { print STDERR "$_\n"; $_->require } list_packages($_) for (@{$self->{'search_path'}});
62
63 # return blank unless we've found anything
64164µs return () unless @plugins;
65
66
67
68 # remove duplicates
69 # probably not necessary but hey ho
70 my %plugins;
71 for(@plugins) {
72100782µs532.07ms next unless $self->_is_legit($_);
# spent 2.07ms making 53 calls to Module::Pluggable::Object::_is_legit, avg 39µs/call
73 $plugins{$_} = 1;
74 }
75
76 # are we instantiating or requring?
77375µs if (defined $self->{'instantiate'}) {
78 my $method = $self->{'instantiate'};
79 return map { ($_->can($method)) ? $_->$method(@_) : () } keys %plugins;
80 } else {
81 # no? just return the names
82 return keys %plugins;
83 }
84
85
86}
87
88
# spent 127µs within Module::Pluggable::Object::_setup_exceptions which was called 3 times, avg 42µs/call: # 3 times (127µs+0s) by Module::Pluggable::Object::plugins at line 37, avg 42µs/call
sub _setup_exceptions {
8933118µs my $self = shift;
90
91 my %only;
92 my %except;
93 my $only;
94 my $except;
95
96 if (defined $self->{'only'}) {
97 if (ref($self->{'only'}) eq 'ARRAY') {
98 %only = map { $_ => 1 } @{$self->{'only'}};
99 } elsif (ref($self->{'only'}) eq 'Regexp') {
100 $only = $self->{'only'}
101 } elsif (ref($self->{'only'}) eq '') {
102 $only{$self->{'only'}} = 1;
103 }
104 }
105
106
107223µs if (defined $self->{'except'}) {
108 if (ref($self->{'except'}) eq 'ARRAY') {
109 %except = map { $_ => 1 } @{$self->{'except'}};
110 } elsif (ref($self->{'except'}) eq 'Regexp') {
111 $except = $self->{'except'}
112 } elsif (ref($self->{'except'}) eq '') {
113 $except{$self->{'except'}} = 1;
114 }
115 }
116 $self->{_exceptions}->{only_hash} = \%only;
117 $self->{_exceptions}->{only} = $only;
118 $self->{_exceptions}->{except_hash} = \%except;
119 $self->{_exceptions}->{except} = $except;
120
121}
122
123
# spent 4.14ms within Module::Pluggable::Object::_is_legit which was called 95 times, avg 44µs/call: # 53 times (2.07ms+0s) by Module::Pluggable::Object::plugins at line 72, avg 39µs/call # 42 times (2.07ms+0s) by Module::Pluggable::Object::handle_finding_plugin at line 259, avg 49µs/call
sub _is_legit {
12410214.49ms my $self = shift;
125 my $plugin = shift;
126 my %only = %{$self->{_exceptions}->{only_hash}||{}};
127 my %except = %{$self->{_exceptions}->{except_hash}||{}};
128 my $only = $self->{_exceptions}->{only};
129 my $except = $self->{_exceptions}->{except};
130
131 return 0 if (keys %only && !$only{$plugin} );
132 return 0 unless (!defined $only || $plugin =~ m!$only! );
133
134 return 0 if (keys %except && $except{$plugin} );
135 return 0 if (defined $except && $plugin =~ m!$except! );
136
137 return 1;
138}
139
140
# spent 93.5ms (635µs+92.8) within Module::Pluggable::Object::search_directories which was called 3 times, avg 31.2ms/call: # 3 times (635µs+92.8ms) by Module::Pluggable::Object::plugins at line 58, avg 31.2ms/call
sub search_directories {
14115119µs my $self = shift;
142 my @SEARCHDIR = @_;
143
144 my @plugins;
145 # go through our @INC
146 foreach my $dir (@SEARCHDIR) {
14736403µs7293.0ms push @plugins, $self->search_paths($dir);
# spent 92.8ms making 36 calls to Module::Pluggable::Object::search_paths, avg 2.58ms/call # spent 206µs making 36 calls to Regexp::DESTROY, avg 6µs/call
148 }
149 return @plugins;
150}
151
152
153
# spent 92.8ms (11.0+81.8) within Module::Pluggable::Object::search_paths which was called 36 times, avg 2.58ms/call: # 36 times (11.0ms+81.8ms) by Module::Pluggable::Object::search_directories at line 147, avg 2.58ms/call
sub search_paths {
1542162.38ms my $self = shift;
155 my $dir = shift;
156 my @plugins;
157
158 my $file_regex = $self->{'file_regex'} || qr/\.pm$/;
# spent 247µs making 36 calls to Module::Pluggable::Object::CORE:qr, avg 7µs/call
159
160
161 # and each directory in our search path
162 foreach my $searchpath (@{$self->{'search_path'}}) {
163 # create the search directory in a cross platform goodness way
1642073.69ms9613.0ms my $sp = catdir($dir, (split /::/, $searchpath));
# spent 13.0ms making 96 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 136µs/call
165
166 # if it doesn't exist or it's not a dir then skip it
167 next unless ( -e $sp && -d _ ); # Use the cached stat the second time
# spent 1.01ms making 96 calls to Module::Pluggable::Object::CORE:ftis, avg 10µs/call # spent 10µs making 5 calls to Module::Pluggable::Object::CORE:ftdir, avg 2µs/call
168
169 my @files = $self->find_files($sp);
# spent 6.45ms making 5 calls to Module::Pluggable::Object::find_files, avg 1.29ms/call # spent 22µs making 5 calls to Regexp::DESTROY, avg 4µs/call
170
171 # foreach one we've found
172 foreach my $file (@files) {
173 # untaint the file; accept .pm only
1743504.47ms50771µs next unless ($file) = ($file =~ /(.*$file_regex)$/);
# spent 630µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 25µs/call # spent 142µs making 25 calls to Module::Pluggable::Object::CORE:regcomp, avg 6µs/call
175 # parse the file to get the name
176 my ($name, $directory, $suffix) = fileparse($file, $file_regex);
# spent 3.68ms making 25 calls to File::Basename::fileparse, avg 147µs/call
177
178 next if (!$self->{include_editor_junk} && $self->_is_editor_junk($name));
# spent 986µs making 25 calls to Module::Pluggable::Object::_is_editor_junk, avg 39µs/call
179
180 $directory = abs2rel($directory, $sp);
# spent 28.8ms making 25 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 1.15ms/call
181
182 # If we have a mixed-case package name, assume case has been preserved
183 # correctly. Otherwise, root through the file to locate the case-preserved
184 # version of the package name.
185 my @pkg_dirs = ();
186451.47ms if ( $name eq lc($name) || $name eq uc($name) ) {
187 my $pkg_file = catfile($sp, $directory, "$name$suffix");
# spent 2.66ms making 9 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 296µs/call
188 open PKGFILE, "<$pkg_file" or die "search_paths: Can't open $pkg_file: $!";
# spent 533µs making 9 calls to Module::Pluggable::Object::CORE:open, avg 59µs/call
189 my $in_pod = 0;
19045932µs9326µs while ( my $line = <PKGFILE> ) {
# spent 326µs making 9 calls to Module::Pluggable::Object::CORE:readline, avg 36µs/call
191 $in_pod = 1 if $line =~ m/^=\w/;
# spent 23µs making 9 calls to Module::Pluggable::Object::CORE:match, avg 3µs/call
192 $in_pod = 0 if $line =~ /^=cut/;
# spent 16µs making 9 calls to Module::Pluggable::Object::CORE:match, avg 2µs/call
193 next if ($in_pod || $line =~ /^=cut/); # skip pod text
# spent 14µs making 9 calls to Module::Pluggable::Object::CORE:match, avg 2µs/call
194 next if $line =~ /^\s*#/; # and comments
# spent 19µs making 9 calls to Module::Pluggable::Object::CORE:match, avg 2µs/call
19527215µs18471µs if ( $line =~ m/^\s*package\s+(.*::)?($name)\s*;/i ) {
# spent 364µs making 9 calls to Module::Pluggable::Object::CORE:regcomp, avg 40µs/call # spent 107µs making 9 calls to Module::Pluggable::Object::CORE:match, avg 12µs/call
196 @pkg_dirs = split /::/, $1;
197 $name = $2;
198 last;
199 }
200 }
201 close PKGFILE;
# spent 126µs making 9 calls to Module::Pluggable::Object::CORE:close, avg 14µs/call
202 }
203
204 # then create the class name in a cross platform way
205 $directory =~ s/^[a-z]://i if($^O =~ /MSWin32|dos/); # remove volume
# spent 238µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 10µs/call
206 my @dirs = ();
207751.10ms if ($directory) {
208 ($directory) = ($directory =~ /(.*)/);
# spent 167µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 7µs/call
209 @dirs = grep(length($_), splitdir($directory))
# spent 594µs making 25 calls to File::Spec::Functions::__ANON__[File/Spec/Functions.pm:43], avg 24µs/call
210 unless $directory eq curdir();
211 for my $d (reverse @dirs) {
212 my $pkg_dir = pop @pkg_dirs;
213 last unless defined $pkg_dir;
214 $d =~ s/\Q$pkg_dir\E/$pkg_dir/i; # Correct case
215 }
216 } else {
217 $directory = "";
218 }
219 my $plugin = join '::', $searchpath, @dirs, $name;
220
221 next unless $plugin =~ m!(?:[a-z\d]+)[a-z\d]!i;
# spent 169µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 7µs/call
222
223 my $err = $self->handle_finding_plugin($plugin);
# spent 14.1ms making 25 calls to Module::Pluggable::Object::handle_finding_plugin, avg 565µs/call
224 carp "Couldn't require $plugin : $err" if $err;
225
226 push @plugins, $plugin;
227 }
228
229 # now add stuff that may have been in package
230 # NOTE we should probably use all the stuff we've been given already
231 # but then we can't unload it :(
232 push @plugins, $self->handle_innerpackages($searchpath);
# spent 7.20ms making 5 calls to Module::Pluggable::Object::handle_innerpackages, avg 1.44ms/call
233 } # foreach $searchpath
234
235 return @plugins;
236}
237
238
# spent 986µs (835+150) within Module::Pluggable::Object::_is_editor_junk which was called 25 times, avg 39µs/call: # 25 times (835µs+150µs) by Module::Pluggable::Object::search_paths at line 178, avg 39µs/call
sub _is_editor_junk {
2391501.23ms my $self = shift;
240 my $name = shift;
241
242 # Emacs (and other Unix-y editors) leave temp files ending in a
243 # tilde as a backup.
244 return 1 if $name =~ /~$/;
# spent 63µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 3µs/call
245 # Emacs makes these files while a buffer is edited but not yet
246 # saved.
247 return 1 if $name =~ /^\.#/;
# spent 44µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 2µs/call
248 # Vim can leave these files behind if it crashes.
249 return 1 if $name =~ /\.sw[po]$/;
# spent 44µs making 25 calls to Module::Pluggable::Object::CORE:match, avg 2µs/call
250
251 return 0;
252}
253
254
# spent 18.5ms (1.86+16.7) within Module::Pluggable::Object::handle_finding_plugin which was called 53 times, avg 350µs/call: # 28 times (1.05ms+3.35ms) by Module::Pluggable::Object::handle_innerpackages at line 297, avg 157µs/call # 25 times (806µs+13.3ms) by Module::Pluggable::Object::search_paths at line 223, avg 565µs/call
sub handle_finding_plugin {
2552371.58ms my $self = shift;
256 my $plugin = shift;
257
258 return unless (defined $self->{'instantiate'} || $self->{'require'});
259 return unless $self->_is_legit($plugin);
# spent 2.07ms making 42 calls to Module::Pluggable::Object::_is_legit, avg 49µs/call
260 $self->_require($plugin);
# spent 14.6ms making 36 calls to Module::Pluggable::Object::_require, avg 406µs/call
261}
262
263
# spent 6.45ms (478µs+5.97) within Module::Pluggable::Object::find_files which was called 5 times, avg 1.29ms/call: # 5 times (478µs+5.97ms) by Module::Pluggable::Object::search_paths at line 169, avg 1.29ms/call
sub find_files {
26430422µs my $self = shift;
265 my $search_path = shift;
266 my $file_regex = $self->{'file_regex'} || qr/\.pm$/;
# spent 34µs making 5 calls to Module::Pluggable::Object::CORE:qr, avg 7µs/call
267
268
269 # find all the .pm files in it
270 # this isn't perfect and won't find multiple plugins per file
271 #my $cwd = Cwd::getcwd;
272 my @files = ();
273 { # for the benefit of perl 5.6.1's Find, localize topic
27410118µs local $_;
275 File::Find::find( { no_chdir => 1,
276
# spent 1.26ms (958µs+298µs) within Module::Pluggable::Object::__ANON__[/usr/lib/perl5/5.10.1/Module/Pluggable/Object.pm:281] which was called 30 times, avg 42µs/call: # 25 times (838µs+260µs) by File::Find::_find_dir at line 926 of File/Find.pm, avg 44µs/call # 5 times (120µs+38µs) by File::Find::_find_dir at line 854 of File/Find.pm, avg 32µs/call
wanted => sub {
277 # Inlined from File::Find::Rule C< name => '*.pm' >
278801.36ms60250µs return unless $File::Find::name =~ /$file_regex/;
# spent 141µs making 30 calls to Module::Pluggable::Object::CORE:match, avg 5µs/call # spent 109µs making 30 calls to Module::Pluggable::Object::CORE:regcomp, avg 4µs/call
279 (my $path = $File::Find::name) =~ s#^\\./##;
# spent 48µs making 25 calls to Module::Pluggable::Object::CORE:subst, avg 2µs/call
280 push @files, $path;
281 }
282 }, $search_path );
# spent 5.92ms making 5 calls to File::Find::find, avg 1.18ms/call
283 }
284 #chdir $cwd;
285 return @files;
286
287}
288
289
# spent 14.7ms (1.55+13.2) within Module::Pluggable::Object::handle_innerpackages which was called 13 times, avg 1.13ms/call: # 8 times (1.13ms+6.39ms) by Module::Pluggable::Object::plugins at line 59, avg 941µs/call # 5 times (412µs+6.79ms) by Module::Pluggable::Object::search_paths at line 232, avg 1.44ms/call
sub handle_innerpackages {
29078568µs my $self = shift;
291 return () if (exists $self->{inner} && !$self->{inner});
292
293 my $path = shift;
294 my @plugins;
295
296 foreach my $plugin (Devel::InnerPackage::list_packages($path)) {
# spent 8.78ms making 13 calls to Devel::InnerPackage::list_packages, avg 675µs/call
29756855µs284.40ms my $err = $self->handle_finding_plugin($plugin);
# spent 4.40ms making 28 calls to Module::Pluggable::Object::handle_finding_plugin, avg 157µs/call
298 #next if $err;
299 #next unless $INC{$plugin};
300 push @plugins, $plugin;
301 }
302 return @plugins;
303
304}
305
306
307
# spent 14.6ms (10.6+4.00) within Module::Pluggable::Object::_require which was called 36 times, avg 406µs/call: # 36 times (10.6ms+4.00ms) by Module::Pluggable::Object::handle_finding_plugin at line 260, avg 406µs/call
sub _require {
3081803.14ms my $self = shift;
309 my $pack = shift;
310 local $@;
31112.72ms eval "CORE::require $pack";
312 return $@;
313}
314
315
31616µs1;
317
318=pod
319
320=head1 NAME
321
322Module::Pluggable::Object - automatically give your module the ability to have plugins
323
324=head1 SYNOPSIS
325
326
327Simple use Module::Pluggable -
328
329 package MyClass;
330 use Module::Pluggable::Object;
331
332 my $finder = Module::Pluggable::Object->new(%opts);
333 print "My plugins are: ".join(", ", $finder->plugins)."\n";
334
335=head1 DESCRIPTION
336
337Provides a simple but, hopefully, extensible way of having 'plugins' for
338your module. Obviously this isn't going to be the be all and end all of
339solutions but it works for me.
340
341Essentially all it does is export a method into your namespace that
342looks through a search path for .pm files and turn those into class names.
343
344Optionally it instantiates those classes for you.
345
346This object is wrapped by C<Module::Pluggable>. If you want to do something
347odd or add non-general special features you're probably best to wrap this
348and produce your own subclass.
349
350=head1 OPTIONS
351
352See the C<Module::Pluggable> docs.
353
354=head1 AUTHOR
355
356Simon Wistow <simon@thegestalt.org>
357
358=head1 COPYING
359
360Copyright, 2006 Simon Wistow
361
362Distributed under the same terms as Perl itself.
363
364=head1 BUGS
365
366None known.
367
368=head1 SEE ALSO
369
370L<Module::Pluggable>
371
372=cut
373
# spent 126µs within Module::Pluggable::Object::CORE:close which was called 9 times, avg 14µs/call: # 9 times (126µs+0s) by Module::Pluggable::Object::search_paths at line 201 of Module/Pluggable/Object.pm, avg 14µs/call
sub Module::Pluggable::Object::CORE:close; # xsub
# spent 10µs within Module::Pluggable::Object::CORE:ftdir which was called 5 times, avg 2µs/call: # 5 times (10µs+0s) by Module::Pluggable::Object::search_paths at line 167 of Module/Pluggable/Object.pm, avg 2µs/call
sub Module::Pluggable::Object::CORE:ftdir; # xsub
# spent 1.01ms within Module::Pluggable::Object::CORE:ftis which was called 96 times, avg 10µs/call: # 96 times (1.01ms+0s) by Module::Pluggable::Object::search_paths at line 167 of Module/Pluggable/Object.pm, avg 10µs/call
sub Module::Pluggable::Object::CORE:ftis; # xsub
# spent 1.67ms within Module::Pluggable::Object::CORE:match which was called 250 times, avg 7µs/call: # 30 times (141µs+0s) by Module::Pluggable::Object::__ANON__[/usr/lib/perl5/5.10.1/Module/Pluggable/Object.pm:281] at line 278 of Module/Pluggable/Object.pm, avg 5µs/call # 25 times (630µs+0s) by Module::Pluggable::Object::search_paths at line 174 of Module/Pluggable/Object.pm, avg 25µs/call # 25 times (238µs+0s) by Module::Pluggable::Object::search_paths at line 205 of Module/Pluggable/Object.pm, avg 10µs/call # 25 times (169µs+0s) by Module::Pluggable::Object::search_paths at line 221 of Module/Pluggable/Object.pm, avg 7µs/call # 25 times (167µs+0s) by Module::Pluggable::Object::search_paths at line 208 of Module/Pluggable/Object.pm, avg 7µs/call # 25 times (63µs+0s) by Module::Pluggable::Object::_is_editor_junk at line 244 of Module/Pluggable/Object.pm, avg 3µs/call # 25 times (44µs+0s) by Module::Pluggable::Object::_is_editor_junk at line 247 of Module/Pluggable/Object.pm, avg 2µs/call # 25 times (44µs+0s) by Module::Pluggable::Object::_is_editor_junk at line 249 of Module/Pluggable/Object.pm, avg 2µs/call # 9 times (107µs+0s) by Module::Pluggable::Object::search_paths at line 195 of Module/Pluggable/Object.pm, avg 12µs/call # 9 times (23µs+0s) by Module::Pluggable::Object::search_paths at line 191 of Module/Pluggable/Object.pm, avg 3µs/call # 9 times (19µs+0s) by Module::Pluggable::Object::search_paths at line 194 of Module/Pluggable/Object.pm, avg 2µs/call # 9 times (16µs+0s) by Module::Pluggable::Object::search_paths at line 192 of Module/Pluggable/Object.pm, avg 2µs/call # 9 times (14µs+0s) by Module::Pluggable::Object::search_paths at line 193 of Module/Pluggable/Object.pm, avg 2µs/call
sub Module::Pluggable::Object::CORE:match; # xsub
# spent 533µs within Module::Pluggable::Object::CORE:open which was called 9 times, avg 59µs/call: # 9 times (533µs+0s) by Module::Pluggable::Object::search_paths at line 188 of Module/Pluggable/Object.pm, avg 59µs/call
sub Module::Pluggable::Object::CORE:open; # xsub
# spent 281µs within Module::Pluggable::Object::CORE:qr which was called 41 times, avg 7µs/call: # 36 times (247µs+0s) by Module::Pluggable::Object::search_paths at line 158 of Module/Pluggable/Object.pm, avg 7µs/call # 5 times (34µs+0s) by Module::Pluggable::Object::find_files at line 266 of Module/Pluggable/Object.pm, avg 7µs/call
sub Module::Pluggable::Object::CORE:qr; # xsub
# spent 326µs within Module::Pluggable::Object::CORE:readline which was called 9 times, avg 36µs/call: # 9 times (326µs+0s) by Module::Pluggable::Object::search_paths at line 190 of Module/Pluggable/Object.pm, avg 36µs/call
sub Module::Pluggable::Object::CORE:readline; # xsub
# spent 614µs within Module::Pluggable::Object::CORE:regcomp which was called 64 times, avg 10µs/call: # 30 times (109µs+0s) by Module::Pluggable::Object::__ANON__[/usr/lib/perl5/5.10.1/Module/Pluggable/Object.pm:281] at line 278 of Module/Pluggable/Object.pm, avg 4µs/call # 25 times (142µs+0s) by Module::Pluggable::Object::search_paths at line 174 of Module/Pluggable/Object.pm, avg 6µs/call # 9 times (364µs+0s) by Module::Pluggable::Object::search_paths at line 195 of Module/Pluggable/Object.pm, avg 40µs/call
sub Module::Pluggable::Object::CORE:regcomp; # xsub
# spent 48µs within Module::Pluggable::Object::CORE:subst which was called 25 times, avg 2µs/call: # 25 times (48µs+0s) by Module::Pluggable::Object::__ANON__[/usr/lib/perl5/5.10.1/Module/Pluggable/Object.pm:281] at line 279 of Module/Pluggable/Object.pm, avg 2µs/call
sub Module::Pluggable::Object::CORE:subst; # xsub