Thanks for the suggestions.  I'm pretty new to Perl, as you can tell.  I
came from Javascript most recently, and (sorry) Visual Basic.  I am a linux
user and fan, although I'm writing this from work, where I have to use
Windows.  I mainly posted this script to try to help the person who posted
a Net::POP3 question a couple of days ago.

Shawn




                                                                                       
                            
                    bigj@kamelfre                                                      
                            
                    und.de               To:     [EMAIL PROTECTED]                    
                            
                                         cc:                                           
                            
                    10/08/2002           bcc:                                          
                            
                    02:14 PM             Subject:     Re: Net::POP3                    
                            
                                                                                       
                            
                                                                                       
                            




Shawn Milochik wrote:

> I was just playing with Net::POP3 this past weeked.  Here's a working
> script.  It's not great, but I got the basics working, and you can mess
> with it.
>


It's a nice script, the only things that could be improved is to write
it more Perlish :-)


> #!/usr/bin/perl


use strict;
use warnings;


> #use Net::FTP;
> use Net::POP3;
> $result = undef;


Define the variables where you need them.


> print "Enter the server name:\n";
> $popServer = <STDIN>;
>
> print "Enter your user name:\n";
> $popUser = <STDIN>;
>
> print "Enter your password:\n";
> $popPass = <STDIN>;
>
> chomp($popServer);
> chomp($popUser);
> chomp($popPass);



You could also write a little bit  shorter way with
print "Enter the server name:\n";
chomp( my $pop_server = <STDIN> );


....
....


> @message = undef;
>
> $pop = Net::POP3->new($popServer);
>
> $result = $pop->user($popUser);
> print "POP3 logon successful.\n" if $result == 1;


Or
$pop->user($popUser) or die "POP3 logon wasn't succesful";


>
> $numMessages = $pop->pass($popPass);
> print "Number of messages: $numMessages.\n    \n";
>
> if ($numMessages > 0){


It's also enough to ask for messages :-):
if ($num_messages) { ...


>
>    for ($x=1;$x<=$numMessages;$x++){


foreach my $x (1 .. $num_messages) {


>       $result = $pop->get($x);
>       @message = @$result;


         my @msg_line = @{$pop->get($x)};


>
>       print "\nInfo for message $x of $numMessages:\n";
>
>       foreach $message (@message){
>
>          print $message if $message =~ /subject:/i;
>          print $message if $message =~ /from:/i;
>       }


Or
print grep {/subject:/i || /from:/i} @message;


>       print "\n\n";
>    }
> }
>
>
>
> $result = $pop->quit();
> print "POP3 logout successful.\n" if $result == 1;


$pop->quit or die "POP3 logout didn't succeed\n";


Cheerio,
Janek


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







**********************************************************************
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**********************************************************************


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to