This is in regards to my question concerning looping on a growing hash. For more background on this refer to How do I...? - Looping on a growing hash.
First...thanx to kanji and jeffa for their help on the LOOP trigger.
Some background
=============================
I have a hash called %links that is structured in the following manner:
%links{URL_NAME}{count} # of occurances (this URL)
{depth} Number of pages from root doc
{title} text in TITLE tag
{text} HTML-stripped contents of page
{visited} flag to indicate traversal
The URL_NAME key will be the absolute URL (http://www.someserver.com/somedir/somepage.html) to the page in question. This %links hash will contain a list of URLs that I want to visit in order to build a data file from the resulting traversal with the data in the completed %links hash.
What I'm attempting to do
=============================
I am looking for the best way to retrieve a entry from the hash that has {visited} UNDEFined (or maybe even set to 0...must likely UNDEFined). The current suggestions are to do something along the lines of:
my @keys = grep ! defined $links{$_}->{'visi ted'}, keys %links;
However, this code recreates the array with every value in the hash that matches the condition which is more than I want. Besides, the hash could contain hundreds of entries and this just adds to the processing overhead.
To keep processing fast and extranous information at a minimum, I only need 1 URL_NAME to be returned at a time. The returning order is unimportant as the loop will process all the entries anyways.
Is it possible to return just 1 entry and reduce total processing cycles? If so, how?
A better question might be: Am I really speeding things up by getting 1 entry....will the REGEX process the entire hash before returning 1 entry anyways? Is processing an issue on an array that contains X number of entries that gets recreated X - 1 times each pass?
As always...pro/con input graciously accepted.
======================
Sean Shrum
http://www.shrum.net
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |