regex - Perl: Finding out the unavailable string in a txt file -
I'm starting a new one in Perl, which is using strawberry-pearl,
I A Perl script is written to find special strings in a text file,
===================================
====================================
Here's my code,
#! My @ eatables = ("fruit", "meat", "vegetable"); Open (FH, "& lt; sample.txt") or die "sample can not open txt: $!" ;; Sub head () {while (my $ line = & lt; FH & gt;) {foreach (@Itables) {if ($ line = ~ m / $ _ /) {print "found: $ _ line $. \ N "; }}} Closed (FH); } Main(); 1;
I found the following print,
found: Line 1 on the fruit was found: found fruit on fruit 2 found: vegetable on line 3 found: fruit Found on line 4: The vegetable was found on line 5: The vegetable was found on line 6: Line 7 on the fruit found: found on the vegetable line 8: Line 9 on the fruit found: fruit 10 on the line
< / Pre>I do not find "found" in my console here: "Print" is required because the sample 'meat' is not available anywhere in the sample. Txt What can I use to make it? Or do I need to modify my search logic? help please.
Thanks in advance,
Regards Ramkumar KA
In this way you can know how many times the epi is in each string.
Comments
Post a Comment