#!/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
#
data.txt
This is the first line of text.
And a second line of text.
---------
A third line of text.
Now a fourth line of text.
---------
The fifth line of text.
Finally, the sixth line of text.
No comments:
Post a Comment