Thanks for your help. Tried this, and $code appears to be empty. I've declared it outside the While loop, but it prints out as null. Should this contain the total substitutions?
Well, for one thing I wouldn't regard $code as a particularly good variable name. Then, if you want the total number of substitutions, you must accumulate them:
$count += s/\band\b/$word/ig;
In reply to Re^3: Counting instances of words
by blazar
in thread Counting instances of words
by scarymonster
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |