Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Please Perl Monks, you are my only hope...#!/usr/bin/perl #Start the modules use strict; use CGI; #Create a new CGI object my $Page = new CGI; #Take the inoformation from the CGI module my $Info = $Page->param("words"); #Print out an HTML MIME Header print $Page->header; #Print out the proper HTML print <<HTMLSTUFF; <html> <head> <title> Your results </title> <style language="text/css"> <!-- p { font-family: Arial, Times New Roman, Garamond; } //--> </style> </head> <body bgcolor="lightGreen"> HTMLSTUFF #Check to see if the information has only one word if ($Info =~ m/ /) { print "<p>Please use only one word.</p>\n"; print <<MOREHTML; </body> </html> MOREHTML exit; } #Make sure the file can be opened unless (open (FILE, "<../Names.html")) { print "<p>Make sure the file is there</p>\n"; print <<MOREHTML; </body> </html> MOREHTML exit; } #Read the whole thing into an array my @Lines = <FILE>; #Close the file close (FILE); #Use "grep" to find the goods my @Names =~ grep("$Info", @Lines); my $i; ############The whole thing #Print out the word "Results print "<p>Here's the results</p>\n"; #Print out all of that shit #Do a "for" loop to print each of the names for ($i=0; $i<=@Names; $i++) { print "<p>$Names[$i]</p>\n"; } ##########End it all print "</body>\n"; print "</html>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looking through a file...
by BeernuT (Pilgrim) on Mar 31, 2002 at 06:03 UTC | |
|
Re: Looking through a file...
by zengargoyle (Deacon) on Mar 31, 2002 at 06:33 UTC |