say i have two strings "xxxxyyyyxxxx" and "zzzz". i want to replace characters 4-7 in the first string with the second string with an emphasis on speed.
basically i want to do what can be done in c with the following: char str1[13] = "xxxxyyyyxxxx"; char *str2 = "zzzz"; strncpy(str1+4, str2, 4); so far all i can come up with in perl is: my $str1 = 'xxxxyyyyxxxx'; my $str2 = 'zzzz'; $str1 = substr($str1, 0, 4) . $str2 . substr($str1, 8, 4); now obviously the c code is always going to be faster, but is there any way i can optimize the perl code? in answering the question, please note that i only have offsets into the string to work with, i.e. i can't say $str1 =~ s/yyyy/$str2/; to be more clear: "i want to replace characters n thru m with a new string of length m-n, but i don't know what characters n thru m are." thanks for the help. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>