B::Xref is recommended in some of the nodes that planetscape listed. B::Xref generates a cross reference listing of all definitions and uses of variables, subroutines and formats in a Perl program. Here is loosely tested code that uses B::Xref to detect unreferenced subroutines:

use strict; use warnings; my $script_name = shift or die; my @lines = `perl -MO=Xref,-r $script_name` or die; my %used_subs; my %defined_subs; foreach (@lines) { my ($file, $subr, $line, $package, $type, $object, $event) = split; next if $file ne $script_name or $type ne '&' or $package ne 'main'; if ( $event eq 'subdef' ) { $defined_subs{$object} = 1; } elsif ( $event eq 'subused' ) { $used_subs{$object} = 1; } } foreach my $key ( sort keys %defined_subs ) { next if $used_subs{$key}; print "Sub not directly called: '$key'\n"; }


In reply to Re: Write Coding to validate the .pl Files by Util
in thread Write Coding to validate the .pl Files by kanish

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.