Given the following chunk of code:

#!/usr/bin/env perl use 5.032001; use warnings; my @packages; package Fee; push @packages,__PACKAGE__; sub one { say __PACKAGE__.q{::one}; }; package Fi; push @packages,__PACKAGE__; sub two { say __PACKAGE__.q{::two}; }; { package Foo; push @packages,__PACKAGE__; sub three { say __PACKAGE__.q{::three}; }; }; # End of package Foo! sub four { say __PACKAGE__.q{:four}; }; # Dump symbols for my $package (@packages) { no strict; my %stash = %{"${package}::"}; use strict; warn Data::Dumper->new([\$package,\%stash],[qw(*package *stash)])- +>Deepcopy(1)->Indent(1)->Maxdepth(3)->Sortkeys(1)->Dump(),q{ }; }; 1; __DATA__

While Devel::Examine::Subs suggests:

'one', 'two', 'three', 'four'

dumping the symbols suggests

\'Fee' ( 'one' => *Fee::one ) \'Fi' ( 'BEGIN' => *Fi::BEGIN, 'DATA' => *Fi::DATA, 'four' => *Fi::four, 'two' => *Fi::two ) \'Foo' ( 'three' => *Foo::three )

My attempts to extract the full subroutine names using PPI have been failures. I can get the sub names and I can get the packages but not the needed relationship --- ie Fee::one, Fi::two etc. I would greatly appreciate knowing how to use PPI to extract the subroutine names in conjunction with their containing package.

Thanks!


In reply to extracting subroutine names (together with their packages) via PPI by clueless newbie

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.