in reply to Re: •Re: Web Site Mapper
in thread Web Site Mapper
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
|
|---|