title: Read and Write the file in cgi perl script using xampp apache server?
body: <p>Am going read and write the xml file.
  i upload the xml file using below html code.
  if i put the xml file in cgi-bin folder it will execute and display</p>
  
  <pre><code> #!"C:\xampp\perl\bin\perl.exe"
       use strict;
  use warnings;
  use CGI;
  
  my $cgi = new CGI;
  print $cgi-&gt;header( "text/html" );
  
  print &lt;&lt;END_HERE;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;My First CGI Script&lt;/title&gt;
    &lt;/head&gt;
    &lt;body bgcolor="#FFFFCC"&gt;
      &lt;p&gt;Welcome to Perl CGI&lt;/p&gt;
  
      &lt;form action="/cgi-bin/inputxml.cgi" method="post"
      enctype="multipart/form-data"&gt;
      &lt;p&gt;Files to Upload: &lt;input type="file" name="xml" /&gt;&lt;/p&gt;
      &lt;p&gt;&lt;input type="submit" name="Submit" value="Submit Form" /&gt;&lt;/p&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  END_HERE
  </code></pre>
  
  <p>But if i put the xml file in any other folder or drive (except cgi-bin folder) it shows Can't open data at C:/xampp/cgi-bin/inputxml.cgi</p>
  
  <pre><code>#!"C:\xampp\perl\bin\perl.exe"
              use strict;
              use CGI;
              use Cwd 'abs_path';
              use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
              use File::Basename;
              $CGI::POST_MAX;
              my $safe_filename_characters = "a-zA-Z0-9_.-";
              my $cgi = new CGI;
              print $cgi-&gt;header ( );
              my $file = $cgi-&gt;param('xml');
              my $lines;
              open(DATA,"&lt;$file") or die "Can't open data $!";
              $lines = &lt;DATA&gt;;
              close(DATA);
              print $lines;    
              print abs_path($file);
              open(OUT, '&gt;dirname($file)."\\out_".basename($file)');
              print OUT $lines;
              close(OUT);   
          print &lt;&lt;END_HERE;
  
  &lt;html&gt;
      &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt;Thanks!&lt;/title&gt;
      &lt;style type="text/css"&gt;
      img {border: none;}
      &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;p&gt;Thanks for uploading your file!&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  END_HERE
  
  print "Welcome Come Again";
  </code></pre>
  
  <p>i want to execute the xml file in any folder or drive without the cgi-bin folder please any one help, thanks in advance.</p>