jrasillo has asked for the wisdom of the Perl Monks concerning the following question:

I'm doing pattern matching to an email message file, I want to extract the senders from the file so I'm doing something like this:
if ($line =~ /^From:\b/){whatever}
can anyone tell me what the problem might be? is it the colon that is causing problems?

Replies are listed 'Best First'.
Re: pattern match
by snowcrash (Friar) on Mar 26, 2002 at 07:16 UTC
    Quote from the perlre man page:

    A word boundary ("\b") is a spot between two characters that has a "\w" on one side of it and a "\W" on the other side of it (in either order)

    So, the \b will only match in your case if it is followed by a word character (alphanumeric plus "_"), in your case it's probably followed by whitespace, so it doesn't match.
    hth,
    snowcrash
      Thanks, I thought the \b was to delimit so that if I wanted to match with From: I would only match against that and not any other (i.e. From: whatever) but thanks anyways jorge
Re: pattern match
by gav^ (Curate) on Mar 26, 2002 at 14:41 UTC
    Your problem is that you aren't using a module from CPAN such as Mail::Box or Mail::MboxParser. Reinventing the wheel (badly) isn't a good thing!

    gav^