Skip to content

Instantly share code, notes, and snippets.

@dvinciguerra
Created June 20, 2012 14:26
Show Gist options
  • Save dvinciguerra/2960156 to your computer and use it in GitHub Desktop.
Save dvinciguerra/2960156 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
use Mail::Internet;
my $mail = Mail::Internet->new(\*STDIN);
# carrega informações
my $from = $mail->head->get("From") || "";
my $subject = $mail->head->get("Subject")|| "";
my $body = join("", @{$mail->body}) || "";
# limpa o corpo da mensagem
$body =~ s/^--[0-9a-zA-Z]*$//gi; # remove linha com hash
$body =~ s/^Content-Type:(.+)$//gi; # remove linha content-type
open my $file, ">/tmp/teste-perl.txt" or die $!;
print $file qq{
$from
$subject
$body
};
close $file;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment