use Email::MIME; use Email::MIME::Attachment::Stripper; use File::Slurp qw(slurp write_file); my $infile = '/home/******/Mail/.family.directory/1280915907.6583.I9x0z:2,S'; my $m = Email::MIME->new( scalar slurp $infile ); my $s = Email::MIME::Attachment::Stripper->new( $m, 'force_filename' => 1 ); print $s->message; #displays "Email::MIME=HASH(0xe0fca8)" foreach my $attachment ( $s->attachments ) { write_file( $attachment->{filename}, { buf_ref => \$attachment->{payload} } ) or die "Can't write $attachment->{filename}: $!\n"; }