[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

SV: [FWP] Substitution



On Thu, 21 Jun 1999, Larry Rosler wrote:

> #!/usr/local/bin/perl -w
> #use strict;
>
> my $test = 'foobarbazfoobarbaz';
> my ($pat, $s1, $s2) = qw(bar aaa zzz);
>
> $test =~ s/$pat(.*?)$pat/$s1$1$s2/;
>
> print "$test\n";

I believe the original code substituted multiple occurances of $pat. Not
just two, which your code seems to do. With your example a string such as;

> my $test = 'foobarbazfoobarbazbar';
> 
Would translate into;

"fooaaabazfoozzbazbar"

Which isn't correct...





==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org