When Refactoring Backfires

Next | Previous

The code you are attempting to refactor may be being called with unexpected data . Perhaps it is finding links neither in an HTML document nor in ordinary HTML?

<p> I am a dodgy document </p>.
<a href="http://www.lemonia.org/">This link ought to work.</a>
<a href="/[%wrong%]/x/y/z/32.gif">This one is the kind that might be
generated by some ad hoc templating system</a>.
<a href="/images/cats/<TMPL_VAR NAME="cat">.jpg">My cat, courtesy
of HTML::Template</a>.
Therefore ...

A "contract" with link_extract

Precondition: $doc (arg1) should be an HTML document.
Postcondition: Returns a list of valid URLs corresponding to links in $doc.