HTTP-404 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Extracting info
by tomhukins (Curate) on Apr 07, 2001 at 19:46 UTC

    Mail::Internet is a useful module for parsing email messages.

    If you don't want the overhead of using modules, you could do something like:

    my $from; while (<MAIL>) { my $mail = $_; chomp $mail; next unless substr($mail, 0, 6, '') eq 'From: '; $from = $mail; last; } print "Mail from : $from\n";
Re: Extracting info
by how do i know if the string is regular expression (Initiate) on Apr 07, 2001 at 18:08 UTC
    You're not very specific in your question... but if
    Received: (qmail 21565 invoked by uid 9); 7 Apr 2001 13:27:27 -0000 To: php-general@lists.php.net From: "Andre Bajew" <AndreBajew@TechnologyArt.com> Date: Sat, 7 Apr 2001 08:27:44 -0500

    is in $line, you could:

    my ($extract) = $line =~ m#^(From: .*?)$#m;

    - FrankG

Re: Extracting info
by Chady (Priest) on Apr 07, 2001 at 19:06 UTC

    This could be anything, but I assume you want to retrieve the e-mail from it for some reason

    here's one way to do it:

    # if this all is in the variable $message.. and # all your messages are the same..you can do my ($name, $email) = $message =~ /^From:\s+\"(.*)\"\s+\<(.*)\>$/m; # and you get the name and the e-mail..

    WARNING!!! This is untested


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.