Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,
I'm writing a scrip to send an email with some files uploaded off a form.
The CGI bit works fine - it puts the filehandles of the uploaded files into a hash, and tells me their size, which is correct.
For my email, I'm using MIME::Lite, and for each filehandle, using the attach method, like so:
$body = join("\n", join (" : ", each (%passed))); my $msg = MIME::Lite->new( From => $from, To => $email, Type => 'TEXT', Subject => 'Results from emailtest.pl', Data => $body ); while (($fname, $fh) = each %file_handles) { $msg->attach( Type => 'BINARY', FH => $fh, Filename => $fname, Encoding => 'base64', Disposition => 'attachment' ); } msg -> send;
But it's not working... My first thought is that if I had just one filehandle I would pass it FH => \*FILEHANDLE, maybe I should be using FH => \$fh.
Or is this nonsense?
Thanks for your help

Replies are listed 'Best First'.
Re: passing filehandles from a hash
by grep (Monsignor) on Jan 04, 2002 at 23:41 UTC
    To check for those errors,I generally like to have the server log files right there as I debug so I can see any errors that the script produces. The server (whether IIS, Apache, or anything else) should be trapping your STOUT and STDERR and put that message in to the log files.

  • Apache (on *nix) logs are kept (usually) in /var/log/httpd/ or /var/log/. You can check the /etc/httpd/conf/httpd.conf, if it is not in those 2 places.
  • Apache (on Win) you'll have to check the httpd.conf
  • Win (with ISAPI) check \perl\bin\perlIS-Err.log.

    If I did not list your server, you can check the docs and find out where this log files are.


    grep
    grep> cd pub grep> more beer
Re: passing filehandles from a hash
by Stegalex (Chaplain) on Jan 04, 2002 at 22:51 UTC
    What error are you getting?
    I like chicken.
      normal cgi error, nothing happens, it times out. But I've tried printing the message to SDTOUT and it works with FH => $fh but doesn't work with FH => \$fh, so it's not that... chicken is dull except with mexican chocolate sauce. try fugu.

      Edited: chipmunk 2002-01-05