Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-04-16 07:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found