il file lo devi chiamare upload.cgi

(nota che devi creare una dir upload nella stessa dir che contiene lo script)

codice:
#!/usr/bin/perl

use strict;
use warnings;
use CGI;
use CGI::Carp "fatalsToBrowser";

my $q = new CGI();

my $submit = $q->param('submit') || undef;

  if ($submit)
  {

    my $file = $q->param('UPLOAD') || die "Error:  You did not select a file!!\n$!";
    my ($name) = ($file =~ m|([^\\/]+)$|);
    
    my $upload_path = 'upload/ ' .  $name;
  
    open(LOCAL, ">$upload_path") || die "Error:  $upload_path\n$!";
    binmode(LOCAL);
    while(<$file>) {
        print LOCAL $_;
    }
    close(LOCAL);
  
    chmod (0644,"$upload_path");
  
    print "Content-type: text/html","\n\n";
    print qq~<html><body bgcolor="#9ECAEB">Il file $name \&egrave; stato trasferito con successo!!</body></html>~;

  } else {
  
    print "Content-type: text/html","\n\n";
    print qq~
     <html>
     <head>
     <title></title>
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
     </head>
     <body bgcolor="#9ECAEB" TOPMARGIN="10" LEFTMARGIN="15">
     <h2>Upload files:</h2>
     <form ENCTYPE="multipart/form-data" ACTION="upload.cgi" METHOD="POST">
     <input type="hidden" NAME="DO" VALUE="UPLOAD">
     

Please select a file to upload: 

     <input type="file" NAME="UPLOAD">
     </p>
     <input type="submit" NAME="submit" value=" submit ">
     </form>
     </body>
     </html>~;
    
  }
Ciao!