Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Matching multiple patterns with regex

by Corion (Patriarch)
on Oct 30, 2015 at 13:50 UTC ( [id://1146491]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Matching multiple patterns with regex
in thread Matching multiple patterns with regex

Can you formulate in English when you want to print a line? The && operator stands for the logical AND, which is true when both its left side and its right side are true. In your case, the current logic means that the line must contain both at the same time, the string Subject: and string From:. You most likely want something else, and describing it in English is usually beneficial to then translating from precise English to Perl code.

Replies are listed 'Best First'.
Re^4: Matching multiple patterns with regex
by Tiarcon (Initiate) on Oct 30, 2015 at 14:11 UTC
    Course, apologies. So I'm trying to capture both the "Subject" and the "from" line of an email(.msg file) and the to print both lines. I know my logic is flawed I just don't have enough experience to know ho to address it Rgds

      Take a plain-text look at the .msg file. Are "Subject" and "from" on the same line? As Msgr.Laurent_R notes, below but prior to creation of this note) and as Corion hinted (before your first, very rude, reply) that may be the issue.

      Then please note that to ensure your questions/comments are written so there can be no misunderstanding, put data like those in your various notes INSIDE <c>...</c> TAGS and be careful to make them exact. The lower case "f" in the parent could confuse or discourage those who try to help but are merely scanning the thread to determine whether or not to bother.

      And don't bother repeating that you don't "know ho(sic) to address (your flawed logic)": Pope Corion had already told you... and, in any case, such an assertion as you made suggests you're not making any real effort to learn.

      This site (Super Search, Tutorials and its published suggestions for raising your questions (On asking for help, How do I post a question effectively? & Markup in the Monastery), the "standard" Perl books (for some mutable value of "standard") such as "Learning Perl" and the wealth of documentation (viz: perldoc perldoc which is available at your own command prompt) have been extremely helpful to some (/me included) who have been in your shoes.

      EDIT: changed incorrect "above" to below in para 1.

      EDIT 2: And what I really set out to mention, before launching on the diatribe above, was that "You don't need to escape the colon in your regex."


      Spirit of the Monastery

      Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
      1. code
      2. verbatim error and/or warning messages
      3. a coherent explanation of what "doesn't work actually means.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1146491]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found