First off the '/sg' switches aren't needed. 's' is 'single' mode (so
saith Freidl/Owl), changing the behaviour of '.' to allow it to match
newlines - that's it! 'g' means repeat for every instance in the match.
The first part, allowing parens to work in a pattern string wasn't so bad,
but I couldn't get the '$1' to interpolate, so, even though it would set
the magic '$1':
my $Text = "before some text some text some text after" ;
my $Search = "some text \(some text\) some text" ;
my $Replace = 'New Text $1 New Text' ;
print "T1: $Text\n";
if ( $Text =~ s/$Search/$Replace/ ) {
print "T2: $Text ($1)\n";
my $one = $1;
$Text =~ s/\$1/$one/;
print "T3: $Text \n";
} else {
print "nope\n";
print "Tn: $Text ($1)\n";
}
a
Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
Contrariwise," continued Tweedledee, "if it was so, it might be, and
if it were so, it would be; but as it isn't, it ain't. That's logic!"
-- Lewis Carroll, "Through the Looking Glass"
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs