#! /usr/bin/perl -w # scr07D.pl # How to search a text string among incoming lines? # Please use "Regular Expression" which has a whole set of text matching grammar. # Regular Expression is placed in two regular slashes /.../. open (IN, "Ref.txt"); while( <IN> ) ## Get One-line each time from an external file "Ref.txt". { ## If incoming text line has my favorite nuts, ## then print out only that text line. ## <= Here comes a Regular Expression. if ( /chestnut/ || /walnut/ ) { print "Found a line of text, which has my favorite nuts : $_"; } } close (IN);