in reply to How to read the file from stdin using perl?

I think the OP is looking for something like this:
use strict; use warnings; my $input_file='file.txt'; while (1){ # Infinite loop print "Enter the word you are looking for (or 'quit' to exit): "; my $answer = <STDIN>; chomp $answer; # remove newline char from answer last if $answer =~/quit/i; # Exit loop print "Looking for '$answer'\n"; my $found = 0; open my $f, "<", $input_file or die "ERROR: Cannot open $input_file + : $!"; while (<$f>) { m/$answer/ or next; $found=1; last; } close $f; if ($found){ print "Found $answer!\n"; }else{ print "Sorry - $answer was not found\n"; } }

        ...Disinformation is not as good as datinformation.               Don't document the program; program the document.