Hi

I had posted this program few days back under code section with the hope that the feedback receive would help fresh 'Perl' programmers like me to improve our skills. So I would request all the perl monks out there to guide me (us) on improving this program.

Regards

Jamnet

#!/usr/bin/perl -w use Net::POP3; # Connect to pop3 server my $pop3 = Net::POP3->new("10.10.10.10") || die "Error : Couldn't log +on to server"; # Login to pop3 server my $Num_Message = $pop3->login("dummy", "dummy"); my $Messages = $pop3->list(); my ($MsgId, $MsgDate, $MsgFrom, $MsgTo, $MsgCc, $MsgSub); my ($MsgAttach, $MsgSize, $MsgHeader, $MsgHeadFlg, $MsgBody); foreach $MsgNo (keys %$Messages) { my $MsgContent = $pop3->get($MsgNo); my $count = 0; $MsgHeadFlg = 0; $MsgBody = ""; print "Message No : $MsgNo\n"; $MsgSize = $pop3->list($MsgNo); print "Message Size : $MsgSize Bytes\n"; # Process message data while() { # Exit if last line of mail if ($count >= scalar(@$MsgContent)) { print "$MsgBody"; last; } # Check if end of mail header if (@$MsgContent[$count] =~ /^\n/) { $MsgHeadFlg = 1; } # Proceed if message header not processed if (not $MsgHeadFlg) { # Split the line my @LineContent = split /: /, @$MsgContent[$count]; # Check Header Info SWITCH: { # Get message date $LineContent[0] =~ /Date/i && do { $MsgDate = $LineContent[1]; print "Date : $MsgDate"; last SWITCH; }; # Get message id $LineContent[0] =~ /Message-ID/i && do { $MsgId = $LineContent[1]; print "Message ID : $MsgId"; last SWITCH; }; # Get message from $LineContent[0] =~ /From/i && do { $MsgFrom = $LineContent[1]; print "From : $MsgFrom"; last SWITCH; }; # Get message to $LineContent[0] =~ /To/i && do { $MsgTo = $LineContent[1]; print "To : $MsgTo"; last SWITCH; }; # Get message cc $LineContent[0] =~ /Cc/i && do { $MsgCc = $LineContent[1]; print "Cc : $MsgCc"; last SWITCH; }; # Get message subject $LineContent[0] =~ /Subject/i && do { $MsgSub = $LineContent[1]; print "Subject : $MsgSub"; last SWITCH; }; } } else { # Process message body $MsgBody .= @$MsgContent[$count]; } $count++; } } # Disconnect from pop3 server $pop3->quit();

In reply to Evaluation of Simple Pop3 Client by Jamnet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.