Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I am having a problem printing the filename on a condition.

I have successfully run the following code, which prints the entire two emails that are contained in the folder.

<br>use strict; <br>use warnings; <br>use Email::Outlook::Message; <br> <br>for my $filename ( glob("C:/path/to/folder/with/email/files/*.msg" +) ) { <br> <br> my $msg = new Email::Outlook::Message $filename; <br> my $mime = $msg->to_email_mime; <br>print $mime->as_string; <br>}

What I'd like PERL to do is read the file, search the body for the work "training", then print the name of the file only if the body contains the keyword.

One email contains the keyword and the other doesn't. Let's say the file names are "email 1.msg" and "email 2.msg". The first contains the work "training" in the body, the other doesn't. I want PERL to print only "email 1.msg" because it contains the keyword.

Seems I need to use an IF statement and =~/commit/ somewhere.

Note: the larger application will be to search thousands of emails within a folder.

Discipulus fixed code tags


In reply to Re^6: Reading msg file by monkee
in thread Reading msg file by shylaja

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (3)
    As of 2020-02-25 03:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?










      Results (108 votes). Check out past polls.

      Notices?