in reply to Re: Re: grabbing certain lines
in thread grabbing certain lines

Well this is what I did
if(/^(((From:)|(To:)|(Reply-To:)).+)/){ print "$1\n";
This give me the whole line. i.e. From: misterbob <bob@mister.com> But now I want to get rid of the From:, To: or what ever is before the ":" and keep misterbob and <bob@moster.com>. I tried splitting on ":" but that didn't seem to work for me. Please advise. Thank you.

Replies are listed 'Best First'.
Re: Re: Re: Re: grabbing certain lines
by Popcorn Dave (Abbot) on Nov 11, 2002 at 23:57 UTC
    I believe if you just change your code to:

    print $2 if ($text =~ /^(From|To|Reply-To):\s+(.+)/);

    That works for me in your test example.

    What you should be doing is looking for the .+ part of your regex and you're not saving that bit. You need to say (.+) and look at $2 and you should be fine. I also moved the : outside your or statement as there's no need that I know of to type that : 3 times when you can get away with once. :)

    Hope that helps!

    There is no emoticon for what I'm feeling now.