It doesn't print any content because the while at the top exits immediately.

The while at the top exits immediately because you opened the file for appending (>>) instead of for reading (<).

I think I see what you intend to do: you want to use the file as a queue, where you append new URLs to the end, and read unprocessed ones from the start (middle).

A file is the wrong type of a datastructure for that.

You could use an array, where you push new URLs in at one end, and shift them out at the other.

Of course, in a real webcrawler, that array is going to get rather large.


In reply to Re: Re: Re: Useless use of substr in void context by Anonymous Monk
in thread Useless use of substr in void context by mkurtis

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.