Web Hosting Talk







View Full Version : simple perl php or cgi question


node9
10-21-2001, 08:32 PM
simple perl questoin guys

i want to make a .pl file... where it'll print this to hello.txt

<a href="game-class:1">1</a>
<a href="game-class:2">2</a>
<a href="game-class:3">3</a>
<a href="game-class:4">4</a>
<a href="game-class:5">5</a>
<a href="game-class:6">6</a>
you konw
it'll go up to 400
so basically, it'll print <a href="game-class:$NUM">$NUM</a>
and output to hello.txt
later ill rename it to .html
could this be done simply?

cperciva
10-21-2001, 08:46 PM
for $i (1..400) {print "<a href=\"game-class:$i\">$i</a>\n";}

Lawrence
10-22-2001, 05:25 AM
Or if you're a really pedantic Perl programmer who likes to whine about unnecessary variables and leaning toothpick syndrome, you might try this:

print qq|<a href="game-class:$_">$_</a>\n| for (1..400);

(No, I'm not such a programmer, but aren't all Perl discussions supposed to be like this :D)

node9
10-22-2001, 07:48 AM
thanks guys

Chicken
10-22-2001, 09:43 AM
Originally posted by Lawrence
(No, I'm not such a programmer, but aren't all Perl discussions supposed to be like this :D)

Yes, they are. I rather enjoy the Perl programmers whittling the code down, heh. Did you ever see that show, "Name That Tune" ? We need a new geeky show called, "Write That Routine" where contestants have to write the shortest, cleanest scripts. Well, maybe not, but...

Lawrence
10-22-2001, 11:36 AM
Originally posted by Chicken


Yes, they are. I rather enjoy the Perl programmers whittling the code down, heh. Did you ever see that show, "Name That Tune" ? We need a new geeky show called, "Write That Routine" where contestants have to write the shortest, cleanest scripts. Well, maybe not, but...

How about a new forum for it then? :D

Any takers on map { print qq|<a href="game-class:$_">$_</a>\n| } (1..400); ?

This could catch on Chicken!

niekas
10-24-2001, 04:43 AM
in PHP its also would be very simple

for ($i = 1; $i <= 400; print "<a href=\"game-class:$i\">$i</a><br>", $i++) ;