Create Free Websites
Create a Free Website at Ucoz
GrrooP.com
Jimdo.comSign Up
MoonFruit


Create Your Own
Designs

Without Tables

Artisteer - Web Design Generator

Use your knowledge of HTML to turn your template into a website.

Download a FREE Trial

PERL CGI Tutorial
for Writing Interactive Form Scripts

Display a File in a Table

Simple modifications can be made to display_file.pl to display the multi line file in a table. The code includes the sorting routine and the split function. A chomp function is added to remove new line characters from the array.

display_table.pl

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

print "<html>\n";
print "<head><title></title></head>\n";
print "<body>\n";
print "<table cellpadding=5 border=1>\n";
print "<tr><th>First Name</th><th>Last Name</th></tr>\n";

open(INFO, "names.txt");
@array=<INFO>;
close (INFO);

chomp(@array);

@sortedarray=sort(@array);

foreach $line (@sortedarray){
($last,$first)=split(/\|/,$line);
print "<tr><td>$first</td><td>$last</td></tr>\n";
}

print "</table>\n";
print "</body>\n";
print "</html>\n";

Remember to Refresh the page after modifications.

Try the Script