PDA

View Full Version : subroutine not displaying the value


id10error
03-07-2005, 05:39 AM
Hi:

I am trying to process a subroutine. The problem is that is not displaying the value of the variable but the name of the variable. I need to display the value (makes sense). I have include most of the code. Some was left out for clarity.

After running some code, check the status. If the status is SUCCESS, run the subroutine subname1 (All of this works perfectly).

I had a similiar problems weeks ago with another code and I was told to leave the print 'EndOfHTML' (single quotes) out and it would display the variable value instead of the variable name. It worked. But now I only have 1 print << and I dont know where to add the second print without the single quotes to makes this work properly. Can anyone help me with this problems please.

TIA


*********************************************
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";

a lot of code here ( everything works here )

if ($status eq "SUCCESS") {
# successfull
my %transaction;

foreach my $response_line (@response) {
my ($key, $value) = split "=", $response_line;
$transaction{$key} = $value;
}
subname1();

# **************************************************
# Everything cool, process this as HTML

sub subname1 {

print <<'EndOfHTML';
<html>
<head>
<title>Cool</title>
<link href="Cool-Text.css" type="text/css" rel="stylesheet">

</head>

<body link="#0000FF" vlink="#808080" leftmargin="10" topmargin="0" background="backgrnd.jpg">

<table border="1" width="812" id="Table001" bordercolor="#FFFFFF" cellspacing="1" >
<tr>
<td>
<div align="left">
<table border="1" width="812" id="Table002" bordercolor="#800000" cellspacing="0" cellpadding="0" height="140">
<tr>
<td width="56%" height="24">
<div style="position: absolute; width: 600px; height: 15px; z-index: 1; left: 2px; top: 6px" id="Layer01">
<font color="#9999FF" face="Arial">Cool</font></b>
</div>
<img border="0" src="picture01.gif" width="812" height="24"></td>
</tr>
<td width="56%">
<table border="1" width="100%" id="Table003" bordercolor="#00FF00" cellspacing="1" height="474">
<tr>
<td width="5%" rowspan="3">&nbsp;</td>
<td width="90%" height="23">&nbsp;</td>
<td width="5%" rowspan="3">&nbsp;</td>
</tr>
<tr>
<td width="90%" valign="top">&nbsp;<p>&nbsp;</p>
<p align="center"><b><font color="#00CCFF" face="Arial" size="3">Your processing number is ...:</font></b></p>
<p align="center">
<b><font face="Arial" size="3">&nbsp;
<p align="center"><font size="5" face="Arial" color="#FFFF00"><b>$transaction{'item_number'}</b></font></p>
<br>&nbsp;</font>
<form method="post" action="/cgi-bin/nextpage.cgi">
<input type="hidden" name="item_number" value="$transaction{'item_number'}">
<p align="center">
<input type="submit" value="Click here to Continue!"></a></p>
</form></b>
</td>
</tr>
<tr>
<td width="90%" height="23">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
EndOfHTML
}

mlseim
03-07-2005, 05:50 AM
I usually do it this way (not that it's the correct way ...) ...
(all the changes I've made in RED).

=======================================================

*********************************************
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";

a lot of code here ( everything works here )

if ($status eq "SUCCESS") {
# successfull
my %transaction;

foreach my $response_line (@response) {
my ($key, $value) = split "=", $response_line;
$transaction{$key} = $value;
}
&subname1;

# **************************************************
# Everything cool, process this as HTML

sub subname1 {

print qq~
<html>
<head>
<title>Cool</title>
<link href="Cool-Text.css" type="text/css" rel="stylesheet">

</head>

<body link="#0000FF" vlink="#808080" leftmargin="10" topmargin="0" background="backgrnd.jpg">

<table border="1" width="812" id="Table001" bordercolor="#FFFFFF" cellspacing="1" >
<tr>
<td>
<div align="left">
<table border="1" width="812" id="Table002" bordercolor="#800000" cellspacing="0" cellpadding="0" height="140">
<tr>
<td width="56%" height="24">
<div style="position: absolute; width: 600px; height: 15px; z-index: 1; left: 2px; top: 6px" id="Layer01">
<font color="#9999FF" face="Arial">Cool</font></b>
</div>
<img border="0" src="picture01.gif" width="812" height="24"></td>
</tr>
<td width="56%">
<table border="1" width="100%" id="Table003" bordercolor="#00FF00" cellspacing="1" height="474">
<tr>
<td width="5%" rowspan="3">&nbsp;</td>
<td width="90%" height="23">&nbsp;</td>
<td width="5%" rowspan="3">&nbsp;</td>
</tr>
<tr>
<td width="90%" valign="top">&nbsp;<p>&nbsp;</p>
<p align="center"><b><font color="#00CCFF" face="Arial" size="3">Your processing number is ...:</font></b></p>
<p align="center">
<b><font face="Arial" size="3">&nbsp;
<p align="center"><font size="5" face="Arial" color="#FFFF00"><b>$transaction{'item_number'}</b></font></p>
<br>&nbsp;</font>
<form method="post" action="/cgi-bin/nextpage.cgi">
<input type="hidden" name="item_number" value='$transaction{'item_number'}'><p align="center">
<input type="submit" value="Click here to Continue!"></a></p>
</form></b>
</td>
</tr>
<tr>
<td width="90%" height="23">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>
~;
}