[EMAIL PROTECTED] wrote:

> 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";
>        }

You could also try :

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";
eval "\$Text =~ s/$Search/$Replace/";
print "T2: $Text\n";


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to