I am a beginner to Perl. Well, I have a scenario like this. I have a
pattern like VIOLATE in the file. So, I want to use the perl to search
that pattern and see how many times it found such pattern. [Trimmed].


I am a beginner too but try this:
my $count
while my $filevar (<file>) 
{
        while ($filevar =~ /VIO\w*LATE/)
        {
                ++$count;
        }
}

I think that this will work because Regular Expressions are very greedy, and will try 
to match as much as they can. So by puttting in the \w* in the middle, it will match 
if it is VIOLATE or if it is VIOLATE ABC VIOLATE. However it will also match VIO YOU 
LATE?

Would someone tell me if this is wrong becuase I have only been doing perl for a week, 
but I have been learning it very fast.

Brian

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to