in reply to Re: uninitialized values for arrays suddenly appear
in thread uninitialized values for arrays suddenly appear
#!/usr/local/bin/perl -w # Define Variables # $basedir = '/home/mysite/www/'; $baseurl = 'http://www.mysite.com/'; @files = ('*.htm','*.html','*/*.html'); $title = "The Silver Machine"; $title_url = 'http://mysite.com/'; $search_url = 'http://www.mysite.com/search.html'; # Done # ###################################################################### +######## # Parse Form Search Information &parse_form; # Get Files To Search Through &get_files; # Search the files &search; # Print Results of Search &return_html; sub parse_form { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } } sub get_files { chdir($basedir); foreach $file (@files) { $ls = `ls $file`; @ls = split(/\s+/,$ls); foreach $temp_file (@ls) { if (-d $file) { $filename = "$file$temp_file"; if (-T $filename) { push(@FILES,$filename); } } elsif (-T $temp_file) { push(@FILES,$temp_file); } } } } sub search { @terms = split(/\s+/, $FORM{'terms'}); foreach $FILE (@FILES) { open(FILE,"$FILE"); @LINES = <FILE>; close(FILE); $string = join(' ',@LINES); $string =~ s/\n//g; if ($FORM{'boolean'} eq 'AND') { foreach $term (@terms) { if ($FORM{'case'} eq 'Insensitive') { if (!($string =~ /$term/i)) { $include{$FILE} = 'no'; last; } else { $include{$FILE} = 'yes'; } } elsif ($FORM{'case'} eq 'Sensitive') { if (!($string =~ /$term/)) { $include{$FILE} = 'no'; last; } else { $include{$FILE} = 'yes'; } } } } elsif ($FORM{'boolean'} eq 'OR') { foreach $term (@terms) { if ($FORM{'case'} eq 'Insensitive') { if ($string =~ /$term/i) { $include{$FILE} = 'yes'; last; } else { $include{$FILE} = 'no'; } } elsif ($FORM{'case'} eq 'Sensitive') { if ($string =~ /$term/) { $include{$FILE} = 'yes'; last; } else { $include{$FILE} = 'no'; } } } } if ($string =~ /<title>(.*)<\/title>/i) { $titles{$FILE} = "$1"; } else { $titles{$FILE} = "$FILE"; } } } sub return_html { open(FH,"../top.html") || die "couldn't open file $!\n"; my @html=<FH>; close(FH); print @html; print "\n <center>\n <h1>Search Results</h1>\n </center>\n"; print "Here ya go, they're in no particular order:<p><hr size=7 wid +th=75%><p>\n"; print "<ul>\n"; foreach $key (keys %include) { if ($include{$key} eq 'yes') { print "<li class=bullets><span class=bullets><a href=\"$baseu +rl$key\">$titles{$key}</a></span></li>\n"; } } print "</ul>\n"; print "\n"; print "</ul><br><hr size=7 width=75%><P>\n"; print "<ul>\n<li class=bullets><span class=bullets><a href=\"$searc +h_url\">Back to Search Page</a></span></li>\n"; print "<li class=bullets><span class=bullets><a href=\"$title_url\" +>$title</a></span></li>\n"; print "</ul>\n"; print "<hr size=7 width=75%>\n"; print "</body>\n</html>\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re(3): uninitialized values for arrays suddenly appear
by Ovid (Cardinal) on Sep 08, 2001 at 00:37 UTC | |
by jerrygarciuh (Curate) on Sep 08, 2001 at 17:50 UTC | |
by jerrygarciuh (Curate) on Sep 08, 2001 at 01:31 UTC | |
by runrig (Abbot) on Sep 08, 2001 at 01:59 UTC | |
|
Re: Re: Re: uninitialized values for arrays suddenly appear
by runrig (Abbot) on Sep 08, 2001 at 00:13 UTC | |
|
Re(3): uninitialized values for arrays suddenly appear
by dragonchild (Archbishop) on Sep 08, 2001 at 00:06 UTC | |
by jerrygarciuh (Curate) on Sep 08, 2001 at 00:43 UTC |