in reply to Re: loading files
in thread loading files

when I change Mail::Internet->new(ARGV[0]); into Mail::Internet->new( ARG, OPTIONS );
and my $entity = $parser->parse(ARGV[0]); into my $entity = $parser->parse(INSTREAM);

I got this:
Bareword "ARG" not allowed while "strict subs" in use at emailprogramma3.txt line 13.
Bareword "OPTIONS" not allowed while "strict subs" in use at emailprogramma3.txt line 13.
Bareword "INSTREAM" not allowed while "strict subs" in use at emailprogramma3.txt line 36.
Execution of emailprogramma3.txt aborted due to compilation errors.

and now?

Replies are listed 'Best First'.
Re^3: loading files
by almut (Canon) on Dec 22, 2008 at 12:57 UTC

    Try

    my $mail_file = $ARGV[0]; open my $mail_fh, "<", $mail_file or die "Couldn't open '$mail_file': +$!";

    and then put $mail_fh where you now have $ARGV[0].

      he will not doing anything with the piece that filters the filename of the attachment. i get: Use of uninitialized value in string ne at emailprogramma3.txt line 71 (the line with if ($file ne ""){ in it) that is the place where I want to print the filename.
      the other piece (mail::internet) works perfectly.

        Have you tried re-opening the file, or alternatively just seek($mail_fh,0,0) to re-position the file pointer to the beginning of the file?

        I didn't actually try it (because I don't have those modules installed), but the following statement from the documentation of Mail::Internet's new() method, i.e. "the new object will be initialized with headers and body" makes me suspect that the module might have already read the entire file (not just the headers), so the file pointer would need to be re-positioned for another read of the file (by MIME::Parser)...