(Sorry about dropping line feeds. "How to use editor" does not open. Is there a manual html-type insertion I can use, like ?) With string: my $kp = "(@array[$i1]*@array2[$i2])*(@array3[$i3]*@array[$i4])"; @array elements are those strings to find: ee, sd .. etc, in the sub tt3' regex substitutions...