1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/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}'"; }
1 2 3 4 5 6
my $daten_bytes_von_smtp = .....; my $output_bytes = undef; open (my $IN, '<', \$daten_bytes_von_smtp) or ...; open (my $OUT, '>', \$output_bytes) or ...; ....; ....parse(\*IN,\*OUT);
QuoteName "main::IN" used only once: possible typo at test.pl line 30.
Name "main::OUT" used only once: possible typo at test.pl line 30.
QuoteNot a GLOB reference at C:/strawberry/perl/site/lib/MIME/Explode.pm line 136.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#!/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; my $daten_bytes_von_smtp = "To: test\@test.de\n\n"; open (my $IN, '<', \$daten_bytes_von_smtp) or die $!; open (my $OUT, '>', 'test.txt') or die $!; require MIME::Explode; my $explode = MIME::Explode->new( output_dir => "tmp", mkdir => 0666, decode_subject => 1, check_content_type => 1, types_action => 'include', ); if (my $headers = $explode->parse(\$IN,\$OUT)) { say Dumper($headers); }