I'm trying to call the Net::POP3 login method from a subroutine. For some reason it returns an undef on me. I know that's an error, but I can't figure out where to go from there. I thought it was going out of scope, so I tried the reset function, but this didn't work. I also tried doing it manually, as you'll see in the code below. It still won't work. What am I doing wrong?
my $pop3 = Net::POP3->new('$host');
###############################
PROMPT: while ($var == 2) {
print '#! ';
$current_input = <STDIN>;
if($current_input =~ /^login/) {
&login;
}
}
###############################
sub login() {
print "logging in...\n";
$pop3 = Net::POP3->new('$host');
LOGIN: if ($numb = $pop3->login("$username", "$password")) { #line
+ 25
system("cls");
print "logged in...\n";
print "you have $numb messages...\n";
} else {
print $numb;
print "couldn't login, try again?[y/n] ";
my $answer = <STDIN>;
if ($answer =~ /y/i) {
goto LOGIN;
}
}
goto PROMPT;
}
The exact error I get when running the script is
Can't call method "login" on an undefined value at mail.pl line 25, <STDIN> line 1.
What's happening? P.S. I'm running Windows 98 IndigoPerl. Thanx for your help,
- p u n k k i d
"Reality is merely an illusion, albeit a very persistant one"
-Albert Einstein
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.