title: How do I find the module dependencies of my Perl script?
body: <p>I want another developer to run a Perl script I have written. The script uses many CPAN modules that have to be installed before the script can be run. Is it possible to make the script (or the <code>perl</code> binary) to dump a list of all the missing modules? Perl prints out the missing modules’ names when I attempt to run the script, but this is verbose and does not list all the missing modules at once. I’d like to do something like:</p>
  
  <pre><code>$ cpan -i `said-script --list-deps`
  </code></pre>
  
  <p>Or even:</p>
  
  <pre><code>$ list-deps said-script &gt; required-modules # on my machine
  $ cpan -i `cat required-modules` # on his machine
  </code></pre>
  
  <p>Is there a simple way to do it? This is not a show stopper, but I would like to make the other developer’s life easier. (The required modules are sprinkled across several files, so that it’s not easy for me to make the list by hand without missing anything. I know about <a href="http://search.cpan.org/~smueller/PAR-0.983/lib/PAR.pm" rel="noreferrer">PAR</a>, but it seems a bit too complicated for what I want.)</p>
  
  <hr/>
  
  <p><strong>Update:</strong> Thanks, Manni, that will do. I did not know about <code>%INC</code>, I only knew about <code>@INC</code>. I settled with something like this:</p>
  
  <pre><code>print join("\n", map { s|/|::|g; s|\.pm$||; $_ } keys %INC);
  </code></pre>
  
  <p>Which prints out:</p>
  
  <pre><code>Moose::Meta::TypeConstraint::Registry
  Moose::Meta::Role::Application::ToClass
  Class::C3
  List::Util
  Imager::Color
  …
  </code></pre>
  
  <p>Looks like this will work.</p>