Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Perl >> Snippet

CGI script to return a file from the server inside an HTML file


#!/usr/local/bin/perl
#
# Read in the data file
# Print out HTML formatted lines
#

$file = 'data.txt' ;                   # Name the file
open (INFO, "<$file" ) ;                # Open the file
@lines = < INFO > ;                      # Read it into an array
close (INFO) ;                          # Close the file

print "<html> <head> <title> PERL output </title> </head> \n " ;
print "  <body> \n " ;

foreach $line ( @lines )                 # assign @lines to $line, one at a time
{                                      # braces {} are required, bracket code
   print " \n   <P> $line   </P>" ;     # print formatted lines to screen
}

print " \n  </BODY> \n </html> \n " ;

#
# DONE
#