title: How to update certain part of text file in perl
body: <p>I have write the code but it is not working fine . I wish to change this "/" to this "\".</p>
  
  <pre><code>use strict;
  use warnings;
  
  open(DATA,"+&lt;unix_url.txt") or die("could not open file!");
  
  while(&lt;DATA&gt;){
  
  s/\//\\/g;
  s/\\/c:/;
  print DATA $_;
  
  }
  
  close(DATA);
  </code></pre>
  
  <p>my original file is </p>
  
  <pre><code>/etc/passwd 
  /home/bob/bookmarks.xml 
  /home/bob/vimrc
  </code></pre>
  
  <p>expected output is </p>
  
  <pre><code>C:\etc\passwd
  C:\home\bob\bookmarks.xml
  C:\home\bob\vimrc 
  </code></pre>
  
  <p>original output is </p>
  
  <pre><code>/etc/passwd
  /home/bob/bookmarks.xml
  /home/bob/vimrc/etc/passwd
  \etc\passwd
  kmarks.xml
  kmarks.xml
  mrcmrc
  </code></pre>