Here's one that I think works... it's not much simpler than the original, but it's another way to do it (I think! -- let me know if I'm missing something) :) #!/usr/local/bin/perl -w $inputstring = "foobarbazfoobarbazfoobarbaz" ; $orig = "bar" ; $pat1 = "aaa" ; $pat2 = "zzz" ; @array = ("$pat1", "$pat2") ; $i = 0 ; $inputstring =~ s/$orig/$array[(!!$i++)]/g ; print "$inputstring\n" ; ... this could be further simplified by switching $pat1 and $pat2 in the array and using (!$i++) for the subscript... I'm not entirely convinced it would be less obfuscated that way, either... Dirk dirkm@buster.dhis.org --------------------------------------- *BSD: The non-breakfast part of this complete breakfast. ==== 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