Perhap's it might be more efficent to check if a link already exists before invoking the sub's foreach?

More efficient, perhaps. However, in my case, I needed to search a number of virtualhosts which may end up linking to each other's front page. If you need to check if a page exists before invoking the spider sub, then that code needs to be duplicated in the initial call. By having the check done at the beginning of the sub, you only need to have one place where the check takes place.

In any case, I doubt the efficiency advantage matters. This program isn't CPU-intensive. It will more likely be limited by your connection to the target domains and (probably to a lesser extent) by the memory overhead of recursive calls and the data structure.

Update: I did notice that CPU usage spikes at the end of the program, when YAML::Dump is called. But that's only done once. (I was worried for a moment that it had managed to get itself stuck in an infinate loop and started eating massive system resources *g*).

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated


In reply to Re: Re: •Re: Web Site Mapper by hardburn
in thread Web Site Mapper by hardburn

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.