Good evening monks, i have a question which has been puzzling me and i can't find a solution... Thus asking!

I have a loop which takes an array that already contains some url's. The array starts processing the url's and after some work for filtering which links i need it adds the links to the array which i use for the loop. And that seems to confuse the program. For and foreach loops don't work for sure, and while loops don't seem to work either.

If i put a number for example x < 900 then the script is executed perfectly but if i leave something like x < links then it doesn't. Is there a solution for a problem like this? (I presume there is!). Thanks for the help in advance.

for(my $x = 0; $x < @links; $x++) { $webcrawler->get($links[$x]); my @more_links = map { $_->[0] } $webcrawler->links; # get Links @more_links = map { URI->new_abs( $_, $base_url ) } @more_links; @more_links = map { /^$base_url/ ? $_ : () } @more_links; # Add the filtered links from the more_links array to the links a +rray push(@links,@more_links); #Finally, recursively go through the array and remove URL's that a +ppear twice or more @links = do { my %z; grep { !$z{$_}++ } @links }; }

In reply to Processing a dynamic array by lampros21_7

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.