Perl change Email Subject

I'm new with Perl and I need to read one email from Exchange and add one ID to the subject with Perl.

I was searching and I had found:

Mail::Internet splits a message into a header object in the Mail::Header class, plus a body. You can get and set individual headers through this object:

my $subject = $obj->head->get("Subject");
$obj->head->replace("Subject", "New subject");

But I simply can't understand how to make the script to change the subject.

Can anyone help?


  • This works for me :

    my $header = $entity->head;
    my $subject = $entity->head->get('subject');
    $header->replace('Subject', "Some new subject");