.------[ Schwedler Kofoed wrote (2002/10/22 at 20:25:01) ]------ | | Hi There, | | I would like to change a array @xx looking like this: | | R23 4587 4985934 3245324 66666 | | to: | | R23 458XXXX7 4985934 3245324 6666XXXX6 | | with other words I would like to insert (not replace) XXXX at character | position 8 and 31. I have have tried to use splice and substr but since the | changes have to occur in the middle of the single scalar ($xx[1] and $xx[5]) | it dos not work (??) | `-------------------------------------------------
I'm going to assume there is a reason this is initially in an array and return it as such but this should do the trick: my $str = join('', @xx); my $first = substr($str, 0, 8); my $second = substr($str, 8, 31); my $third = substr($str, 31); my $new_str = $first . 'XXXX' . $second . 'XXXX' . $third; my @new_array = split(/\s/, $new_str); This is probably not the most optimal way to handle this, but it should have the desired result. --------------------------------- Frank Wiles <[EMAIL PROTECTED]> http://frank.wiles.org --------------------------------- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]