#!/usr/bin/perl use strict; use warnings; use Fcntl qw(:DEFAULT); use Data::Dumper; require Data::Dumper; local $Data::Dumper::Purity; $Data::Dumper::Purity = 1; local $Data::Dumper::Useqq; $Data::Dumper::Useqq = 1; local $Data::Dumper::Sortkeys; $Data::Dumper::Sortkeys = sub { my ($hash) = @_; return [(sort {lc $a cmp lc $b} keys %$hash)]; }; use 5.010; require IO::String; require MIME::Explode; my $fhin = IO::String->new("Date: Sat, 16 Apr 2016 17:24:09 +0200\nSubject: Testsubject\n\nTesttext"); my $fhout = IO::String->new(); my $explode = MIME::Explode->new( decode_subject => 1, check_content_type => 1, types_action => 'include', ); if (my $headers = $explode->parse(*$fhin,*$fhout)) { say Dumper($headers); say '#########################################'; say "Out: '${$fhout->string_ref}'"; }