NotProud has asked for the wisdom of the Perl Monks concerning the following question:
All I want to do is print 'yeppers' if the output from a text file has the word 'cat'. But I cannot get it to work. Here is the code. Any suggestions would be great. and why am I doing this on Friday night? I'm Not Proud
#!/usr/local/bin/perl -w use strict print "Content-Type: text/html\n\n"; print "<html>\n"; print "<body bgcolor=fffbbf>\n"; #this chunk of code out put the input box. Got me? read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @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; $value =~ s/~!/ ~!/g; $value =~ s/\s*$//; $FORM{$name} = $value; # print "$FORM{$name} = $value<br>\n"; } #this is the end of the output code. Got me? $readthis = 'd:/209.35.237.237/perl/regex/work.txt'; open(READTHIS, "< $readthis") or die "I can't open readthis: $!\n"; print (<READTHIS>); print "<br>\n"; print $value; print "<p>\n"; #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #this is the code I can not get to work #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while ($line = <READTHIS>) { if ($line =~ /cat/) { print "yeppers!"; } } #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ print <<EOF; <form name="textwrite" action="work.pl" method="post"> enter something: <input type="text" name="thisone" size="30"> <br> <input type="submit" value="submit"> </form> EOF print "<br></body>\n"; print "</html>";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reg ex matching 101
by Petruchio (Vicar) on Oct 07, 2000 at 07:48 UTC | |
by NotProud (Novice) on Oct 09, 2000 at 05:35 UTC | |
by NotProud (Novice) on Oct 09, 2000 at 05:39 UTC | |
|
RE: reg ex matching 101
by 2501 (Pilgrim) on Oct 07, 2000 at 07:13 UTC | |
by Petruchio (Vicar) on Oct 07, 2000 at 08:36 UTC | |
by chromatic (Archbishop) on Oct 07, 2000 at 20:22 UTC | |
by 2501 (Pilgrim) on Oct 08, 2000 at 03:40 UTC | |
|
RE: reg ex matching 101
by turnstep (Parson) on Oct 07, 2000 at 17:44 UTC | |
|
Re: reg ex matching 101
by NotProud (Novice) on Oct 07, 2000 at 07:33 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |