in reply to replace a column

Hi,
If I understand you correctly, this maybe worth a look.
This uses a regex to only change records that contain the column you want to change. Other records are passed through unchanged.
If the 'x' doesn't actually appear in the data just remove it from the regex. In that case there would need to be at least 2 spaces or tabs in the middle for it to work.
Give us more examples of live data if I've misunderstood you.
#!/usr/bin/perl use strict; use warnings; my @array = qw ( 0.99 0.99 0.99 0.99 ); my $count = 0; while (<DATA>){ if (/^(\d\.\d{2,3}\s+)x(\s+\d\.\d{2,3})/){ print $1, $array[$count++], $2, "\n" } else { print } } __DATA__ 0.00 x 1.000 0.530 x 0.753 # output values for residue 1 0 # input 0.00 x 1.00 0.555 x 0.683 # output values for residue 2 0
produces...
0.00 0.99 1.000 0.530 0.99 0.753 # output values for residue 1 0 # input 0.00 0.99 1.00 0.555 0.99 0.683 # output values for residue 2 0
update: fixed typo