G
Graham Stow
Stupidly, I ran the script below (copied from the book 'Perl - I Didn't Know
You Could Do That...' by Martin C. Brown) without understanding what the
script was doing. Now, none of my Perl scipts run anymore - all that happens
is that the command prompt window is minimised and a Windows Wordpad window
containing my script, pops up. I'm running v5.8.6 on a W32 system. Can
anyone tell me what I've done and how I correct it? Instict tells me it
might have something to do with the use of the Getopt::Std module, but I
really don't know.
use Net:
OP3;
use Net::SMTP;
use Getopt::Std;
getopts('q');
my ($host, $login, $password) = ('atuin', 'mcbmac', 'Tamsin');
my $server = Net:
OP3->new($host, Debug => 99999);
warn "Couldn't connect to server $host" unless $server;
my $nomsgs = $server->login($login, $password);
die "Could not login" unless defined($nomsgs);
my $msglist = $server->list();
$nomsgs = keys %$msglist;
print "There are $nomsgs messages on $host\n";
foreach my $msg_id (keys %$msglist)
{
my $msgcontent = $server->get($msg_id);
forward($msgcontent, '(e-mail address removed)', '(e-mail address removed)');
}
$server->quit();
sub forward
{
my ($message, $from, $to) = @_;
$smtp = Net::SMTP->new('mail');
die "Couldn't open connection to server" unless $smtp;
$smtp->mail($from) or die "Bad 'from' address";
$smtp->to($to) or die "Bad 'to' address";
$smtp->data();
$smtp->datasend(join('',@$message));
die "Connection wouldn't accept data"
unless($smtp->dataend());
}
You Could Do That...' by Martin C. Brown) without understanding what the
script was doing. Now, none of my Perl scipts run anymore - all that happens
is that the command prompt window is minimised and a Windows Wordpad window
containing my script, pops up. I'm running v5.8.6 on a W32 system. Can
anyone tell me what I've done and how I correct it? Instict tells me it
might have something to do with the use of the Getopt::Std module, but I
really don't know.
use Net:
use Net::SMTP;
use Getopt::Std;
getopts('q');
my ($host, $login, $password) = ('atuin', 'mcbmac', 'Tamsin');
my $server = Net:
warn "Couldn't connect to server $host" unless $server;
my $nomsgs = $server->login($login, $password);
die "Could not login" unless defined($nomsgs);
my $msglist = $server->list();
$nomsgs = keys %$msglist;
print "There are $nomsgs messages on $host\n";
foreach my $msg_id (keys %$msglist)
{
my $msgcontent = $server->get($msg_id);
forward($msgcontent, '(e-mail address removed)', '(e-mail address removed)');
}
$server->quit();
sub forward
{
my ($message, $from, $to) = @_;
$smtp = Net::SMTP->new('mail');
die "Couldn't open connection to server" unless $smtp;
$smtp->mail($from) or die "Bad 'from' address";
$smtp->to($to) or die "Bad 'to' address";
$smtp->data();
$smtp->datasend(join('',@$message));
die "Connection wouldn't accept data"
unless($smtp->dataend());
}