in reply to Matching multiple patterns with regex
Hello Tiarcon, and welcome to the Monastery!
Just letting you know that you don’t have to use regular expressions for this. has dedicated modules for reading email. For example:
#! perl use strict; use warnings; use Email::Simple; my $file = 'YourEmailHere.eml'; open(my $fh, '<', $file) or die "Cannot open file '$file' for reading: $!"; my $text = do { local $/; <$fh>; }; close $fh or die "Cannot close file '$file': $!"; my $email = Email::Simple->new($text); my $from = $email->header('From'); my $subject = $email->header('Subject'); print "FROM: $from\n"; print "SUBJECT: $subject\n";
See Email::Simple.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching multiple patterns with regex
by Tiarcon (Initiate) on Oct 30, 2015 at 14:16 UTC |