OK, here's my quickie code. It won't catch fancy things like eval'd subs, etc., but it does what I need.
#!/usr/bin/perl use strict; my %used_sub = (); my %declard_sub = (); my @imported_sub = (); my @reserved = (); my $keywords_define_file = '/System/Library/Perl/darwin/CORE/keywords. +h'; if (open F, $keywords_define_file) { /^#define KEY_(\w+)/ and push @reserved, $1 while (<F>); } close F; while (<>) { while (/(?:\A|[^\%\@\$\w>])(\w+)\s*\(/g) { $used_sub{$1}++; } while (/sub\s+(\w+)/g) { $declard_sub{$1}++; } if (/^use\s+\S+\s+qw\((.*)\)/) { push @imported_sub, $_ foreach split /\s+/, $1; } } delete @used_sub{@reserved}; delete @used_sub{@imported_sub}; print join("\n", 'Declared subs (used):', sort( grep {exists $used_sub{$_}} keys %declard_sub ), '','', 'Declared subs (unused):', sort( grep {!exists $used_sub{$_}} keys %declard_sub ), '','', 'Used subs (declared):', sort( grep {exists $declard_sub{$_}} keys %used_sub ), '','', 'Used subs (undeclared):', sort( grep {! exists $declard_sub{$_}} keys %used_sub ), '' );

In reply to Re: How to check if a word is reserved by genecutl
in thread How to check if a word is reserved by genecutl

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.