PDA

View Full Version : perl debugging HELP!!


outlaw2k
04-08-2003, 09:48 PM
I can't figure out what's wrong, both these scripts don't work and I don't want to use the "PRINT" method,
because it will be harder to read and edit since I'll have to keep escaping
the characters... the path is also right. it outputs the html but not
the variable


#!/usr/bin/perl -w


$Name = $in{'Name'};


print "Content-type: text/html\n\n";
print <<"(END ERROR HTML)";

<html>
<HEAD>
<TITLE>a stupid test!</TITLE>
</HEAD>
<body>
<center>Your name is $Name</center>
</body>
</html>

(END ERROR HTML)
exit;


OR, the following

#!/usr/bin/perl -w


$Name = $in{'Name'};


print "Content-type: text/html\n\n";
print << ENDHTML";

<html>
<HEAD>
<TITLE>a stupid test!</TITLE>
</HEAD>
<body>
<center>Your name is $Name</center>
</body>
</html>

ENDHTML
exit;

Saj
04-09-2003, 04:24 PM
What do you mean "escaping the characters?"

But why don't you do this? It's a lot like the print, but its easier to work with:


#!/usr/bin/perl -w


$Name = $in{'Name'};


print "Content-type: text/html\n\n";
print <<"(END ERROR HTML)";
print qq(
<html>
<HEAD>
<TITLE>a stupid test!</TITLE>
</HEAD>
<body>
<center>Your name is $Name</center>
</body>
</html>)

(END ERROR HTML)
exit;

outlaw2k
04-09-2003, 05:29 PM
escaping the characters means like when using the print function, you'd have to escape any characters that might be mistaken as code... "$" and "&" for instance...like in old versions of perl where you had to type a backslash before an at sign (ie: someone\@domain.com)...that makes the code a lot harder to read and write when working with the html... thanks for the reply,. i'll try it. as of right now, my method worked for printing variables defined within the script, but not input by the user via a form. thanks

Saj
04-09-2003, 07:46 PM
Ok well, with the print qq, you don't need to escape the characters...only $ and & and specified perl characters you would have to. But the biggest pain is quotes, and you don't have to do that here.

outlaw2k
04-09-2003, 09:08 PM
both these don't work and I don't want to use the "PRINT" method, because it will be harder to read and edit since I'll have to keep escaping the characters... the path is also right. it outputs the html but not the variable


#!/usr/bin/perl -w


$Name = $in{'Name'};


print "Content-type: text/html\n\n";
print <<"(END ERROR HTML)";

<html>
<HEAD>
<TITLE>a stupid test!</TITLE>
</HEAD>
<body>
<center>Your name is $Name</center>
</body>
</html>

(END ERROR HTML)
exit;


OR, the following

#!/usr/bin/perl -w


$Name = $in{'Name'};


print "Content-type: text/html\n\n";
print << ENDHTML";

<html>
<HEAD>
<TITLE>a stupid test!</TITLE>
</HEAD>
<body>
<center>Your name is $Name</center>
</body>
</html>

ENDHTML
exit;

Saj
04-09-2003, 11:29 PM
Then try adding a / in front of the $varname. Maybe that would work.

YUPAPA
04-09-2003, 11:38 PM
You don't have the hash for %in