supernewbie has asked for the wisdom of the Perl Monks concerning the following question:
I've tried:$x = 0; $cnt = tr/abc//; $x += $cnt;
This won't work either... So, is there a way to find out how many times string "abc" appeared?$x = 0; while (<DATA>) { $cnt = m/abc/g; $x += $cnt; }
Could any Perl Master enlighten me a little bit?
Edit Masem 2001-07-19 - Moved question text from child node to root node.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tr/abc// won't use string
by Sifmole (Chaplain) on Jul 19, 2001 at 22:37 UTC | |
|
Re: tr/abc// won't use string for matching, then what?
by supernewbie (Beadle) on Jul 19, 2001 at 22:11 UTC | |
by jynx (Priest) on Jul 19, 2001 at 22:33 UTC | |
by supernewbie (Beadle) on Jul 19, 2001 at 22:36 UTC | |
by jynx (Priest) on Jul 19, 2001 at 22:48 UTC | |
|
Re: tr/abc// won't use string
by Hofmator (Curate) on Jul 20, 2001 at 16:24 UTC |