title: Perl Can't modify constant item in substitution
body: <p>I have Perl Script using to remove unnecessary tags that bloating xml pdf files i am creating</p>
  
  <pre><code>#!/usr/bin/perl
  
  #use strict;
  
  use DirHandle;
  
  my $sourcefile = shift;
  my $outputfile = "new" . $sourcefile;
  
  open SOURCEFILE, "$sourcefile" or die;
  open OUTPUTFILE, "&gt;$outputfile" or die;
  
  $flag = 0;
  foreach $line (&lt;SOURCEFILE&gt;) {
    if($line=~ /&lt;\?templateDesigner StyleID aped2\?&gt;\n/) {
      if($flag == 1) {
        line=~ s/[\t]*&lt;\?templateDesigner StyleID aped2\?&gt;\n//gi;
      }
      $flag=1;
    }
    elsif($line=~ /&lt;\?templateDesigner StyleID aped3\?&gt;\n/) {
      if($flag == 1) {
        $line=~ s/[\t]*&lt;\?templateDesigner StyleID aped3\?&gt;\n//gi;
      }
      $flag=1;
    }
    elsif($line=~ /&lt;\?templateDesigner StyleID apcb1\?&gt;\n/) {
      if($flag == 1) {
        $line=~ s/[\t]*&lt;\?templateDesigner StyleID apcb1\?&gt;\n//gi;
      }
      $flag=1;
    }
    else {
      $flag=0;
    }
    print OUTPUTFILE $line;
  }
  
  close SOURCEFILE;
  close OUTPUTFILE;
  </code></pre>
  
  <p>Result of me running this script is following error.</p>
  
  <p>Can't modify constant item in substitution (s///) at d:\Temp\PDFPatch2.pl line 1
  7, near "s/[\t]*&lt;\?templateDesigner StyleID aped2\?>\n//gi;"
  Execution of d:\Temp\PDFPatch2.pl aborted due to compilation errors.</p>
  
  <p>Sorry do not know much about perl.</p>