Consider:
#! /usr/bin/perl
@no = (1 .. 20000);
foreach(@no) {
print "<div id=\"world@no\" onclick=\"javascript:showDiv_postscreen(); javascript:hideDiv_welcomebuttons()\"> </div>\n";
}
This is my Perl script, but how do I get it to rewrite the sentence with a new variable each time?
I.e., how do I get it to output the following?
<div id="world1" onclick="javascript:showDiv_postscreen(); javascript:hideDiv_welcomebuttons()"> </div>
.
.
.
<div id="world20000" onclick="javascript:showDiv_postscreen(); javascript:hideDiv_welcomebuttons()"> </div>
The
@in the print statement is confusing the interpreter. Also, it isn’t what you want, sinceprint "@no"would print out the same thing asjoin(' ',@no). Instead, you want to interpolate each element of@nointo the string that’s printed out: