Oh Wise Fellows-in-Perl
Today I've spent my day thinking about an old and dull problem I have at work: how to analyse and solve dependency problems with legacy source code? I mean, I need to remove old, not used anymore, libraries and references to templates, config options and the like from my source code. Its not huge at all, but I don't want to search for every reference by hand.

My question is: is there any (?:tool|library|program) that could be useful for accomplish this task? I don't even know how to name this job, so I just can't find anything usefull at google or at Seekers of Perl Wisdom.

Please, no ready answers, I need to figure things out by myself, and maybe roll my own solution out-of-the-box. Pointers, libraries, example source code and ideas are all welcome.

Ah! This is something I've coded (sorry, Bourne Again Shell, not Perl) as a proof-of-concept...:

#!/bin/bash function search-for-dependants () { pushd "$1" || exit 1 for template in `find . -type f -print | egrep -v CVS | sed 's/^\.\/ +//;'` do remove=$template if echo $template | egrep -q '\.pm$'; then template=$(echo $template | sed 's/^.*\/lib\///;s/\//::/g;s/\.pm +$//;') fi echo "========================================" echo $template echo "========================================" find ~/src/netfax \ -type f \( -exec egrep -q $template "{}" \; -a -print \) | egrep -v CVS | egrep -v $remove | sort -u echo -e "========================================\n\n" done | sed 's/^\/home\/lcampos\/src\/netfax\///;' | tee ~/tmp/files popd } search-for-dependants ~/src/netfax/components search-for-dependants ~/src/netfax/lib

Update: minor spelling error fixes.


In reply to Source-Code Analysis? by monsieur_champs

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.