Display files
  1. Create a new script with this code:

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

    open (THISFILE,"textthought.txt");

    foreach $line() {
    print "$line<br>\n";
    }

    close (THISFILE);
  2. Save the file as textviewer.pl in the PERLSCRIPTS folder, upload it to the perlscripts directory on the Web server, then set its permissions so that anyone can execute it.

    Here's what the relevant lines in this script do:
  • open (THISFILE,"textthought.txt")

    Opens the file textthought.txt, and assigns the text in it to the file variable THISFILE.

  • foreach $line () {

    The foreach loop loops though every line in the THISFILE variable. In other words, it goes through each line of the textthought.txt file.

    At each line, it assigns the value of that line to the scalar variable $line.