Advertisement

07.10.2008 at 04:35PM PDT, ID: 23555831
[x]
Attachment Details

Extract single line for an array based on text at the start of the line.

Asked by GerryArmstrong in Perl Programming Language

Tags: Perl5

Guys, I am using perl to retrieve email messages from a POP3 account and I wish to extract specific lines of information from the retrieved data based on specific words such as "From:" PLease see the code I have got so far that retrieves the email then prints it to screen.
Any assistance is greatly appreciated.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
#!/usr/local/bin/perl
use strict;
use Net::POP3;
my $server = "mail.cisl.bb";
my $username = 'username';
my $password = "password";
my $messages;
my $message;
my $msgid;
my $pop = Net::POP3->new($server, Debug => 0) ||
    die "Can't open connection to $server : $!\n";
defined ( $pop->login($username, $password) ) ||
    die "Can't authenticate: $!\n";
$messages = $pop->list || die "Can't get list of messages : $!\n";
foreach $msgid (keys %$messages)
   {
   $message = $pop->get($msgid);
  if ( $message )
      { #succeeded
     print "\n"; print @$message;
      }
   else
      { #failed
      warn "Couldn't fetch $msgid from mail server ; $!\n";
      next;
      }
	$pop->delete($msgid);
   }
$pop->quit();
[+][-]07.10.2008 at 04:39PM PDT, ID: 21978349

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 04:41PM PDT, ID: 21978368

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 04:44PM PDT, ID: 21978395

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 04:48PM PDT, ID: 21978406

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 05:52PM PDT, ID: 21979039

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: Perl5
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.10.2008 at 06:02PM PDT, ID: 21979117

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628