in reply to how can i search a text file for a string and print every occurence of that string
Here's a less compicated way to do it.
However with this will not pick up a match that occurs over multiple lines, and it also is not very fast when munging through huge files.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"; } }
|
---|
In Section
Seekers of Perl Wisdom