in reply to Creating an image map using Perl code

You can't just mix code and data like that. Even PHP has markers to separate them :)

Try printing your html:

## Previous code to find x coordinates, y coordinates ## and website names my @x_points; my @y_points; my @websites; my $secondcount; print q( <IMG SRC="figure.gif" USEMAP="#mymap"> <MAP NAME="mymap"> ); for ($secondcount=1; $secondcount <= $webpage_no; $secondcount++) { print qq( <AREA SHAPE=circle COORDS="'$x_points[$secondcount],$y_ +points[$secondcount],1" HREF="'$websites[$secondcount]"> ); } print q( </MAP> );
Accessing an array element still needs a sigil: x_points[$secondcount] doesn't work, you meant to say $x_points[$secondcount].

Oh, and why do you start counting at 1?

Replies are listed 'Best First'.
Re^2: Creating an image map using Perl code
by lampros21_7 (Scribe) on Apr 06, 2006 at 01:45 UTC
    Sorry those were silly mistakes. I still get the same errors now with the sigils though. And i ve started counting from 0 but have removed the = sign from the second argument in the for loop. Is there a way to mix the for loop and the JavaScript/HTML? I still can't run and print my algorithm as i still get the same two errors. Thanks
      The problem must be somewhere else in your code, because the snippet that I posted works (even though it doesn't print any <area> tags).

      Try starting your script with this:

      use strict; use warnings;
      Then try running your script through the perl compiler:  perl -c your_script.pl. That should give you a lot more information about possible causes for the errors.

      If that doesn't help you out, can you post a bit more code?

      Did you notice he also added prints, not just sigils? I see you've (silently) updated your node to add the sigils and to fix the loop bounds, but the prints are still missing.