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

Hi gang, CENTOS 7, perl 5.

I'm having problems with MIME::Parser extracting (correctly) attachments but incorrectly naming them. An attachment defined as :

Content-Type: application/vnd.openxmlformats-officedocument.spreadshee +tml.sheet; name="Copy of 1501733944381-20170803 Dataload.xlsx" Content-Description: Copy of 1501733944381-20170803 Dataload.xlsx Content-Disposition: attachment; filename="Copy of 1501733944381-20170803 Dataload.xlsx"; size=23847; creation-date="Mon, 09 Oct 2017 12:39:28 GMT"; modification-date="Mon, 09 Oct 2017 12:38:40 GMT" Content-Transfer-Encoding: base64
... and code defined as...
my $emailfile = basename("$email"); my $tmpdir = "/tmp/$emailfile"; mkdir "$tmpdir"; my $parser = MIME::Parser->new(); $parser->decode_headers(1); $parser->output_dir("$tmpdir"); my $message = $parser->parse_open("$email");
... and variable $email defined as a full path and filename, I get a file created in /tmp/$emailfilename as
Copy of 150173.xls
Two things. The name is wrong and the suffix is wrong. I can live with the suffix being wrong but it does point to possibly the problem being with the content-type being something MIME::Parser doesn't fully recognise. Anyone come across anything like this? Anyone solve it?