Click to See Complete Forum and Search --> : .cgi vs. .pl


jane_262
01-11-2004, 09:01 PM
I think the problem might be with the Apache server but I am not sure. I am used to using .pl to process my scripts, but for some reason, the error I get is POST not allowed. I use the .cgi extension and Almost everything works. I'd like to display the first variable from each line in a database in a table. It has worked for me in the past using the .pl extension on other servers like this:

<table width="400" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666">
<TBODY>
<COLDEFS><COLDEF>
</COLDEFS><ROWS>
<tr>
<td colstart="1" >&nbsp;</td>
<td colstart="2" >&nbsp;</td>
</tr>
EOF

foreach $lines(@database_array) {
@edit_array = split(/\:/,$lines);

print<<EOF;

<TR><TD
VALIGN="MIDDLE" ALIGN="CENTER" WIDTH="200" COLSTART="1">$edit_array[0]</TD>

EOF
foreach $lines(@database_array2) {
@edit_array2 = split(/\:/,$lines);

print<<EOF;
<TD
VALIGN="MIDDLE" ALIGN="CENTER" WIDTH="200" COLSTART="2">$edit_array2[0]</TD>



</TR>
</rows>
</tbody>
</table>


I open the db in the beginning of the sub like this:


open (DAT,"<$userinfo/011704.db");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
@database_array = <DAT>;
close (DAT);


open (DAT2,"<$nonuserinfo/011704n.db");
if ($LOCK_EX){
flock(DAT2, $LOCK_EX); #Locks the file
}
@database_array2 = <DAT2>;
close (DAT2);



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

&header;
print<<EOF;


Any ideas?

jane_262
01-15-2004, 06:41 PM
Apparently, among other unrelated issues, the first part of the problem was wether or not the database would actually open so I had to include

|| die($!)

and the second part of the problem was the manner in which I tried to display the output. This amended the problem:


my $dbLen =
(@db_array1 > @db_array2)? @db_array1 : @db_array2;
my ($db1,$db2);

for (0..$dbLen) {
($db1) = ($db_array1[$_])? split(/\:/, $db_array1[$_], 2) : '&nbsp;';
($db2) = ($db_array2[$_])? split(/\:/, $db_array2[$_], 2) : '&nbsp;';



For any other persons who may have a similar problem.