I copied the code from Randal's Web Techniques at 
http://www.stonehenge.com/merlyn/WebTechniques/col46.html but I think 
I must have mistyped something because I get the below errors.  I had 
other syntax errors that I fixed but this one I don't have a clue 
about. I'd appreciate any help.

# Bareword "end_multipart_form" not allowed while "strict subs" in use.
File 'Hard Disk:Desktop Folder:CGI/Perl:1 CODE 
SAMPLES:uploadEmailAttach.cgi'; Line 37
# Hard Disk:Desktop Folder:CGI/Perl:1 CODE 
SAMPLES:uploadEmailAttach.cgi had compilation errors.

#!/usr/local/bin/perl -w

use strict;
$|++;

##CONFIGURATION

my $FROM='[EMAIL PROTECTED]';
my $TO='[EMAIL PROTECTED]';
my $SUBJECT='File Upload';
my $INCLUDE_META=1;

##END CONFIGURATION

use CGI qw(:all);

my @params=param();
if (my $error=cgi_error())
{print header(-status=> $error);
  exit(0);
}

print
  header,
  start_html("Upload"),
  h1("Upload"),
  hr,
  start_multipart_form,
  table( Tr( td(p('upload:')),
             td(filefield('uploaded_file'))),
         Tr( td(p('email as type:')),
             td(radio_group('type', [qw(binary text)]))),
         Tr( td({ -colspan=> 2},
                 checkbox(   -name=> 'strip_resource_fork',
                             -label=> 'Strip Macbinary Resource Fork'))),
         Tr( td({-colspan=> 2}, submit))),
  end_multipart_form,
  hr;
if (@params)
{require MIME::Lite->new
     (Type => 'multipart/mixed',
      From => $FROM, To=> $TO, Subject => $SUBJECT);
      if (my $file = upload('uploaded_file')) {
          my $info = uploadInfo($file) or die "info?";
          my $msg = MIME::Lite->new
          (Type => 'multipart/mixed',
           From => $FROM, To => $TO, Subject => $SUBJECT);
 
      if ($INCLUDE_META)
      {$msg->attach
         (Type => 'TEXT', Encoding=> '7bit',
          Data => [
                      "Upload info:\n",
                      (map {"$_=> $info-> {$_}\n"} sort keys %$info),
                      "ENV:\n",
                      (map {"$_=> $ENV{$_}\n"} sort keys %ENV),
                   ],
          );
       }
       $msg->attach
         ((param('type') eq 'text' ?
             (Type=> 'TEXT', Encoding=> 'quoted-printable') :
             (Type=> 'BINARY', Encoding=> 'base64')),
         ((param('strip_resource_fork') &&
             $info->{"Content-Type"} eq "application/x-macbinary") ?
             (Data=>strip_fork_from_fh($file)) :
             (FH=>$file)),
         );
       if ($msg->send_by_smtp('localhost'))
       {print p("Upload sent by email.");
       }
       else
       {print p("An error occurred... here's what would have been sent:"),
        pre($msg->as_string);
       }
      }
     }
     print end_html;
 
     sub strip_fork_from_fh {
         my $fh=shift;
 
         my $len=read $fh, (my $buf), 128; #READ THE HEADER
         die "short read: $len" unless $len==128;
         my $bytes=unpack("x83N", $buf); #GET DATAFORK LENGTH
         read $fh, $buf, $bytes;
         $buf;
     }

#END PROG
*** Teresa Raymond
*** http://www.mariposanet.com
*** [EMAIL PROTECTED]

Reply via email to