Re: newbie question for parsing incoming mails

2017-02-15 Thread Jim Gibson
> On Feb 14, 2017, at 10:38 PM, Eko Budiharto wrote: > > dear all, > I have a question. > If I would like to parse all incoming mails from my qmail, which perl module > is easy to use? > my qmail emails incoming is /var/qmail/mailnames//support. In > this folder I already have preline in .qma

Declaring and conditionally assigning to a variable on the same line

2017-02-15 Thread SSC_perl
I’ve read where writing a one-liner like this is frowned upon: my $show_ref = delete $log{'show_ref'} if (exists $log{'show_ref'}); but what about this? my $show_ref = exists $log{'show_ref'} ? delete $log{'show_ref'} : 'no’; They both seem to work without a problem in my tests.

Re: Declaring and conditionally assigning to a variable on the same line

2017-02-15 Thread Uri Guttman
On 02/15/2017 01:39 PM, SSC_perl wrote: I’ve read where writing a one-liner like this is frowned upon: my $show_ref = delete $log{'show_ref'} if (exists $log{'show_ref'}); there is no need to check for existence when doing delete. it will return undef if it doesn't exist. and also the

Re: newbie question for parsing incoming mails

2017-02-15 Thread Andy Bach
> when I run it, I do not get anything. Hmm, how are you testing it. I put a single header and msg in /tmp/ml.txt (Subject: training.error Trouble wiwb) and: $ parse_email_simple.pl < /tmp/ml.txt training.error Trouble wiwb (8 lines) $ cat /tmp/ml.txt | parse_email_simple.pl training.error Trouble

Re: Declaring and conditionally assigning to a variable on the same line

2017-02-15 Thread SSC_perl
> On Feb 15, 2017, at 11:08 AM, Uri Guttman wrote: > > try the even simpler and cleaner use of || > my $show_ref = delete $log{'show_ref'} || 'no’; Uri, After I had sent in my question, I began wondering if exists was even necessary, so I experimented with the || solution and it worked

Re: newbie question for parsing incoming mails

2017-02-15 Thread Eko Budiharto
Jim, if I want to extract all incoming emails from my qmail emails, how can specify the folder location and specify the file name since the file name always different? Thx. > On Feb 15, 2017, at 22:56, Jim Gibson wrote: > >> >> On Feb 14, 2017, at 10:38 PM, Eko Budiharto wrote: >> >> dear

Re: newbie question for parsing incoming mails

2017-02-15 Thread Eko Budiharto
dear Jim, I tried to add lines to read file like this: use Email::MIME; my $file = '/var/qmail/mailnames//support/Maildir/cur/1487041394.M984019P23084V0803I00E03878.ABCD.NET,S=3987:2,'; open my $ifh, '<', $file or die "Cannot open '$file' for reading: $!"; local $/ = ''; my

Re: newbie question for parsing incoming mails

2017-02-15 Thread Jim Gibson
> On Feb 15, 2017, at 8:10 PM, Eko Budiharto wrote: > > dear Jim, > I tried to add lines to read file like this: > > use Email::MIME; > > my $file = '/var/qmail/mailnames/ name>/support/Maildir/cur/1487041394.M984019P23084V0803I00E03878.ABCD.NET,S=3987:2,'; > open my $ifh,

Re: newbie question for parsing incoming mails

2017-02-15 Thread Jim Gibson
On Feb 15, 2017, at 7:10 PM, Eko Budiharto wrote: > > Jim, > if I want to extract all incoming emails from my qmail emails, how can > specify the folder location and specify the file name since the file name > always different? > > Thx. Use File::Find or opendir and readdir to find all of th

Re: newbie question for parsing incoming mails

2017-02-15 Thread Eko Budiharto
dear all, I have one a couple questions. -. For the header, what if, I just need the subject, the from, and the recipient, what is the command? I read the manual in the https://metacpan.org/pod/Email::MIME#header , it does not tell me how to extract