in reply to Re: Useless use of substr in void context
in thread Useless use of substr in void context

yep you got it jweed, thanks. However this code doesn't work, It doesn't print $content or append anything to urls.txt. My Perl is terrible, so I don't understand why. I just cross my fingers and run it. Thanks
  • Comment on Re: Re: Useless use of substr in void context

Replies are listed 'Best First'.
Re: Re: Re: Useless use of substr in void context
by Anonymous Monk on Feb 21, 2004 at 10:45 UTC
    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.