Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I write same info to TEXT file at the same time?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
This CGI previews changes from another edit page and is suppose to write an identical text file. The CGI previews fine, but is pretty useless without writing to the text file.

What is the correct way to do this?

Thanks for any help.

Tim


------------------------------------------------------------

#!/usr/local/bin/perl
require ('cgi-lib.pl');
$| = 1;

# Print HTML compliant header


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


print <<End_of_Intro;
<HTML>
<HEAD><TITLE>St Martins Staff</TITLE>
<BODY BGcolor=&quot;#FFFFFF&quot;>
<!--#exec cgi=&quot;/cgi-local/axis/ax.pl&quot; -->
<p align=&quot;center&quot;>

<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot; height=&quot;60&quot;>
<tr>
<td width=&quot;100%&quot; align=&quot;center&quot; height=&quot;60&quot;><img border=&quot;0&quot; src=&quot;../../gifs/smdir.gif&quot; width=&quot;315&quot; height=&quot;31&quot;>
<p><font size=&quot;1&quot;><a href=&quot; face=&quot;Trajan&quot;>HOME</font></a><font face=&quot;Trajan,Arial,Helvetica,Geneva&quot;> |
<a href=&quot; | <a href=&quot; | <a href=&quot; | <a href=&quot; | <a href=&quot;| <a href=&quot;
</td>
</tr>
</table>


<hr>
<p align=&quot;center&quot;>
<br>
</p>
<CENTER>
<table border='0' align='center' width='645'>

<tr>

<td width=&quot;375&quot;>
<table width=&quot;628&quot; height=&quot;599&quot;>
<tr align=&quot;left&quot; vAlign=&quot;top&quot;>
<td height=&quot;1&quot; width=&quot;796&quot;><hr size=&quot;1&quot;>

End_of_Intro


$db =&quot;staff.dbf&quot;;
# Open Database file and read all the staff


open (FILE, &quot;<&quot; . $db) || die &quot;Cannot read votes database (staff.dbf)&quot;;
flock (FILE, 2);
for ($loop = 0; $loop <15; $loop++) {
$line[$loop] = <FILE>;
$line[$loop] =~ s/\n$//;
@data = split (&quot;::&quot;, $line[$loop]);
$KEY[$loop] = $data[0];
$NAME[$loop] = $data[1];
$PAGER[$loop] = $data[2];
$POSITION[$loop] = $data[3];
$EMAIL[$loop] = $data[4];
$TELEPHONE [$loop] = $data[5];

}
flock (FILE, 8 );
close (FILE);


# Sort all the lines in the database by vote
@sortline = @line;
foreach (@sortline) {
push (@datakeys, (split(/::/))[6]);
}
sub bydatakeys { $datakeys[$b] <=> $datakeys[$a]; }
@sortdata = @sortline[sort bydatakeys $[..$#sortline];


# Present new table showing staff
print <<End_of_Table;

End_of_Table

$level = 0;
foreach (@sortdata) {
$level ++;
@data = split (&quot;::&quot;, $_);
$KEY = $data[0];
$NAME = $data[1];
$PAGER = $data[2];
$POSITION = $data[3];
$EMAIL = $data[4];

if ($EMAIL eq &quot;&quot;) {
$AHREF = &quot;$NAME&quot;;
}else{
$AHREF = &quot;<a href=\&quot;mailto:$EMAIL\&quot;>$NAME</a>&quot;;
}
$TELEPHONE = $data[5];

print <<End_of_stuff;
<table border=&quot;0&quot; width=&quot;100%&quot; bordercolor=&quot;#FFFFFF&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; height=&quot;20&quot;>
<tr>
<td width=&quot;38%&quot; height=&quot;20&quot;>
<font color=&quot;#800080&quot; face=&quot;Arial&quot;>$POSITION</font></td>
<td width=&quot;62%&quot; height=&quot;20&quot;>
<font face=&quot;Helvetica,Arial&quot; size=&quot;-1&quot;> $AHREF </font></td>
</tr>
<tr>
<td width=&quot;38%&quot; height=&quot;22&quot;><b><font face=&quot;Helvetica,Arial&quot; size=&quot;-1&quot;>$TELEPHONE</font></b></td>
<td width=&quot;62%&quot; height=&quot;22&quot;>$PAGER </td>
</tr>
</table>
<hr size=&quot;1&quot;>
</td>
</tr>
<tr>
<td height=&quot;20&quot; width=&quot;796&quot;>
End_of_stuff

}
print &quot; </table></table></CENTER><br></body></html> \n&quot;;

exit(0);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top