Hi , I have an input file with multiple lines.The code is to search for a particular word in the line and to print the entire line if the word is present.Currently i am using a code as shown below
use strict; my $find = "word or string to find"; open FILE, "<searchfile.txt"; my @line = <FILE>; print "Lined that matched $find\n"; for (@lines) { if ($_ =~ /$find/) { print "$_\n"; } }
But here we are iterating through each line which is time consuming.Is there an easy method?
In reply to Printing th entire line with a keyword by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |