in reply to Re: tr/abc// won't use string for matching, then what?
in thread tr/abc// won't use string


First,

Here's a quick hack that will work:

my $cnt = 0; while (<DATA>) { $cnt++ while m/abc/g; } print "number of entries: $cnt\n";
Second,

While i'm not entirely certain on this (hopefully another monk will straighten this out if i'm wrong), the snippet you tried doesn't work because m// returns whether it matched or not, not the number of times it matches. So if there are lines that have multiple matches, you won't get the total number of matches on that line.

Hope This Helps,
jynx

Update:rewrote my snippet to be more idiomatic...