Is there any way to use a variable in a regex?
Not the predefined variables, but my own variable.
For instance, say I'd like to insert a sentence number at the start of each sentence. Of course I could do it in a loop with index and substr, but is there a way to do it with a global regex? ie:
my $sentenceCount=0;
$str=s/pattern/..stuff..$sentenceCount++...stuff.../g;