in reply to tr/abc// won't use string
Editor's Note - Masem - 2001-07-19 - Please note text of original question was given below with an empty root node; this text has been copied into the root node for completeness' sake.
I understand that tr/abc// use "abc" for matching, instead it uses "a", "b", and "c" to match $_ separately.
Therefore this counting won't work correctly:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: tr/abc// won't use string for matching, then what?
by jynx (Priest) on Jul 19, 2001 at 22:33 UTC | |
|
Re: Re: tr/abc// won't use string for matching, then what?
by supernewbie (Beadle) on Jul 19, 2001 at 22:36 UTC | |
by jynx (Priest) on Jul 19, 2001 at 22:48 UTC |