title: Cut and paste a particular string in a file
body: <p>In a file i need to cut the text(in the form of <code>\qr{....text}</code>) and place 
  after two carriage returns. </p>
  
  <p>Input file text would be :</p>
  
  <pre><code>\section{bla bla ...\qr{text} bla bla..}
  
  Some paragraph text......
  </code></pre>
  
  <p>Required Output:</p>
  
  <pre><code>\section{bla bla bla bla}
  
  \qr{text}......
  Some paragraph text 
  </code></pre>
  
  <p>My attempt:</p>
  
  <pre><code>use strict;
  use warnings;
  
  my $InputXmlFile = $ARGV[0];
  my $OutputXmlFile = $InputXmlFile;
  my $OutProcesText = "";
  $OutputXmlFile =~ s#\.tex$#\.tex#gsi;
  my $workingpath = $1 if $InputXmlFile =~ m/(.*)\\(.+)\.tex/i;
  my $filename = $2 if $InputXmlFile =~ m/(.*)\\(.+)\.tex/i;
  
  open (INTXT, "$InputXmlFile");
  my $inText = join("",&lt;INTXT&gt;);
  close (INTXT);
  
  while($inText =~ m#\\section\{(.*?)\}\n\n#gi) {
      my $qrtext = $1;
      if ($qrtext =~s/\\qr\{(.*?)\}//gi) {
          my $qrFindText = $1;
          $qrtext =~ s/\x0D\x0D/\x0D\x0D$qrFindText/g; 
          print $qrFindText;
      }
      open (FIH,'&gt;',$OutputXmlFile);
      print FIH $inText;
      close(FIH);
  }
  </code></pre>