Help for this page

Select Code to Download


  1. or download this
    die "usage: perl $0 file_nm line_nb col_start col_end replacement \n" 
    +unless @ARGV;
    die "Invalid number of arguments \nusage: perl $0 file_nm line_nb col_
    +start col_end replacement \n" if @ARGV ne 5;
    ...
    chomp ($replacement=`perl -ne "substr($content, $col_start, $col_end, 
    +$string);print $content"`); #get the replaced line
    #print "New content \n$content \n";
    `perl -pi -e "s/$content/$replacement/" $file_nm`; #now substitute the
    + whole line with the new replaced line
    
  2. or download this
    use File::Basename;
    die "usage: perl $0 file_nm line_nb pos_start-pos_end replacement \n" 
    +unless @ARGV;
    ...
    
    close(WRITE_HN);
    close(READ_HN);