in reply to Using variables in RegEx
First of all, there are no "predefined" variables. All variables can be interpolated. The replace expression in a string literal like any other.
s/.../...$foo.../g;
But you want to have Perl code in the replace expression. That's actually possible too. Using /e, the replace expression is treated as a Perl expression.
s/.../$sentenceCount++; foo()/eg;
$sentenceCount doesn't seem to make much sense with s///, though.
$sentenceCount++ while /.../g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using variables in RegEx
by hsfrey (Beadle) on Aug 01, 2008 at 16:48 UTC | |
by ikegami (Patriarch) on Aug 01, 2008 at 20:20 UTC |