A CGI Script that Does Something Useful

A CGI script can do anything a Perl script can do, such as opening files and processing them. Just print your results to STDOUT.

Code:


  #!/usr/bin/perl -w
  # file: process_cosmids.pl

  use strict;
  my $COSMIDS = '/net/share/cgi/cosmids.txt';
  my $URL     = 'http://www.wormbase.org/db/get?class=Sequence;name=';
  
  open (COS,$COSMIDS) or die "Can't open cosmids file: $!\n";
  
  print "Content-type: text/html\n\n";

  print "<html><head><title>Cosmids</title></head><body>\n";
  print "<h1>Cosmids</h1>\n";
  print "<ol>\n";
    
  while (my $cosmid = <COS>) {
     chomp $cosmid;
     print qq(<li><a href="$URL$cosmid">$cosmid</a>);
  }

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

http://your.site/cgi-bin/process_cosmids.pl


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Tue Oct 23 19:24:04 EDT 2001