Discussion Locked

Help with printing HTML in Perl

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am new to perl (progging for about 1/2 a year now) and have stuck to simple code thus far, however, simple code has had me printing increasingly complicated and large HTML pages from the actual program file, and this has obviously resulted in horridly messy code.

So, I decided to step into unknown territories and have so far failed to solve this problem.

That is to say, what I'm trying to do is leave the references on the file then just print the file through the program, therefore slashing the program size and making the code much neater.

However, so far it has not recognised the variable references in the file. (I guess this is a simple problem for you guys, but hey)

here's a snapshot of what I'm doing:

HTML FILE: (created with dreamweaver)

Untitled Document

hello $nick

__________________
Prog: (created with Komodo)

#!/perl/bin -w
print "Content-type: text/html", "\n";
print "Pragma: no-cache", "\n\n";

$nick = "pumpingpump";

open (NICKTEST, "nicktest.htm");

$count = 0;
while ($nicktest = ) {
$nickstore[$count] = $nicktest;
$count += 1;
}

close (NICKTEST);

print (@nickstore);

__________________
the output is:

Content-type: text/html

Pragma: no-cache

Untitled Document

hello $nick

and of course, if you have read the above, I want that $nick in the output to be "pumpingpump"
can you help me?

2 replies

by lawrephord

Could you write an emulator for each instruction in perl using perl then using html then using xml then
using mx then using any other editor ?

by aaraujo

In the body of your while loop, use this:

$nicktest =~ s/\$(\w+)/${$1}/g;
$nickstore[$count] = $nicktest;

instead of simply:

$nickstore[$count] = $nicktest;

Good luck !

This discussion is closed to new replies.