Howdy!
A couple of emendations that don't change the essential meaning but do
affect whether it works as presented...
my @work = fetch_jobs($starting_condition);
my %seen;
while ( @work ) {
# Remove 1 item from our stack/queue
my $job = shift @work;
# Skip this job if we have already done it
next if $seen{$_}++; ## $_ should probably be $job, no?
# Possibly add new jobs to our stack/queue
if ( more_jobs($_) ) { ## $_ should probably be $job, no?
push @work, fetch_jobs($_); ## $_ should probably be $job, no?
}
# process job
}
...because $_ isn't set or otherwise given meaning in this snippet.
while ( @work || @work < 1000 ) { # should ought to be && not ||
}
...otherwise the loop will never exit, as an empty @work will always be
less than 1000...
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|