use strict; use warnings; my ($file_nm,$line_nb,$col_start,$col_end,$string)=@ARGV; open FILE, "<", $file_nm or die "Cannot open file $file_nm!\n"; open OUT, ">", "~$file_nm" or die "Cannot open temp file ~$file_nm for writing!\n"; while(){ substr( $_, $col_start, $col_end-$col_start+1 ) = $string if $.==$line_nb; print OUT $_; } close OUT; close FILE; rename( "~$file_nm", $file_nm );