PERL CGI Tutorial
for Writing Interactive Form Scripts
Display a File in a Scrolling Textarea
Simple modifications can be made to display_file.pl to display the multi line file in a scrolling textarea box. The code includes the sorting routine and the split function. A chomp function is added to remove new line characters from the array.
display_textarea.pl
#!/usr/bin/perl
print "Content-type:text/html\n\n";print "<html>\n";
print "<head><title></title></head>\n";
print "<body>\n";
print "<textarea cols=30 rows=4>\n";open(INFO, "names.txt");
@array=<INFO>;
close (INFO);
chomp(@array);@sortedarray=sort(@array);foreach $line (@sortedarray){
($last,$first)=split(/\|/,$line);
print "File Entry: $first $last\n";
}print "</textarea>\n";
print "</body>\n";
print "</html>\n";
Remember to Refresh the page after modifications.
Contents
Home
Getting Started in CGI
Send HTML Page to Browser
Parse HTML Form
Saving to a File
Open a File and Display Contents
Using the Split Function
Search a File
Sort a File
Display a Multi Line File in Tables
Display a Multi Line File in a Textarea
Working with Numbers
Using Sendmail
Need Web Hosting?
We Recommend these products
Free Flash Websites
