Hi, i have written some code to act like a web crawler but during compilation it gives me a syntax error message. I can't find anything wrong with it so am posting it here:
use WWW::Mechanize; use HTML::TreeBuilder; print "Please input the URL of the site to be searched \n"; my $url_name = <STDIN>; # The user inputs the URL to be searched #Create an instance of the webcrawler our $webcrawler = WWW::Mechanize->new(); our $webcrawler = get($url_name); our @website_links = $webcrawler->links($url_name); # The HTML is stripped off the contents and the text is stored in an +array of strings our $x = 0; our $stripped_html[$x] = $webcrawler( format => "text" ); $x = $x + 1; my @visited_urls = ($url_name); # While the array still has elements(URL's) check the content for lin +ks and strip the HTML while (@website_links) { if ((grep {$_ eq $website_links[0] } @visited_urls) > 0) { # If th +e URL has been visited don't visit again shift @website_links;
It doesn't like the $stripped_html[$x] bit on the 13th line and gives me a syntax error on that. I thought i could use an x variable as a number. What i want to do is then go on a loop and the array will get bigger because my x will increment by 1 every time the loop is done. Any ideas?Thanks

In reply to Weird syntax error message 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.