I need a list of all the subs brought in by the file, not all the subs in the current or main package, and file.pm does not conatin any package declarations.

You can require that file in an ad-hoc package and inspect its symbol table:

#!/usr/bin/perl # file.pm use strict; our ($baz, $quux); sub blorf; $quux = sub { 3 }; sub foo { 1 } sub bar { 2 }
#!/usr/bin/perl # main script use strict; { package Query; require "file.pm"; } print "in package ", __PACKAGE__, $/; for my $sym ( keys %Query:: ) { no strict 'refs'; print "file.pm: $sym\n" if defined *{'Query::'.$sym}{CODE}; print "file.pm: subref \$$sym\n" if ref ${*{'Query::'.$sym}{SCALAR}} + eq 'CODE'; }

Output:

in package main file.pm: sub bar file.pm: subref $quux file.pm: sub blorf file.pm: sub foo

In reply to Re: List of subs defined by a file? by shmem
in thread List of subs defined by a file? by exodist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.