The_Last_Monk has asked for the wisdom of the Perl Monks concerning the following question:

So what i want to be able to do is print the line if a partciular regex appears a particular number of times in that regex. So for example lets say the regex is Goku. I want to print the line if the particular regex Goku appears like 10 times together in a line, so like if goku appears like gokugokugokugokugokugokugokugokugoku, then only it should print that line.
if($textFile =~ /Goku/i){ print $textFile (Only print if goku appears 10 times together in th +at line) }
What would be the best way possible

Replies are listed 'Best First'.
Re: Matching a regex in a line
by toolic (Bishop) on Feb 15, 2015 at 22:42 UTC
    This is one way to print 10 (or more) consecutive "goku" in a line:
    while (<DATA>) { print if /(?:goku){10}/i; } __DATA__ 1 gokugokugokugokugokugokugokugokugokugoku 2 gokugokugokugokugokugoku foo
      You, sir, are a legend!