use File::Basename; die "usage: perl $0 file_nm line_nb pos_start-pos_end replacement \n" unless @ARGV; die "Invalid number of arguments \nusage: perl $0 file_nm line_nb pos_start pos_end replacement \n" if @ARGV ne 5; my ($file_nm,$line_nb,$pos,$string)=@ARGV; my ($pos_start,$pos_end)=split (/-/,$pos); $file_nm=File::Basename::basename($file_nm); open(READ_HN,"$file_nm") or die "Cant open $file_nm $! \n"; open(WRITE_HN,">${file_nm}.updated") or die "Cant write to ${file_nm}.updated $! \n"; #chomp($content=`perl -ne "print if $. == ${line_nb}" $file_nm`); while() { if ($. == $line_nb) { substr($_, $pos_start, $pos_end, $string); } print WRITE_HN "$_\n"; } close(WRITE_HN); close(READ_HN);