Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining modules loaded once program starts

I have a forking server. I load all modules before I fork.

...or do I? I want a message to be logged to STDERR for every module loaded after a certain point in my program.

I was going to use the following, but it's logging some scripts executed using do.

my %ignore = map { $_ => 1 } ( ... );
unshift @INC, sub {
   my (undef, $path) = @_;
   warn("$path wasn't loaded before forking.\n")
      if !$ignore{$path};

   return ();
};

I'm not out of ideas, but before I spend more time on this, I was wondering if there's an existing solution.

like image 719
ikegami Avatar asked May 05 '14 20:05

ikegami


1 Answers

What things are using do? Is simply

if $path =~ /\.pm\z/ && !$ignore{$path};

good enough to distinguish?

Other options:

Static code analysis with PPI (using or based on Module::Extract::Use).

Dump %INC to a file upon SIGHUP or some other signal.

like image 114
ysth Avatar answered Sep 21 '22 13:09

ysth