in reply to Re^2: loading files
in thread loading files

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].

Replies are listed 'Best First'.
Re^4: loading files
by Bass-Fighter (Beadle) on Dec 22, 2008 at 13:55 UTC
    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)...