PDA

View Full Version : Error message: "Can't call method foo without a package or object reference"


bwv
07-20-2004, 07:54 PM
Hello, I know very little about Perl, so any help with this problem would be greatly appreciated.

I am trying to run a script that checks multiple POP3 accounts at once. The script times out, and the error message from the log is "Can't call method "login" without a package or object reference at inbox.pl line xxx."

--I'm on a Unix server, running Perl Version 5.006001

--I do not get the error immediately; it takes about 30 or 40 seconds for the "connection error" text to appear.

--Error messages (generated by "use diagnostics;") from log follows:

Can't call method "login" without a package or object reference at inbox.pl
line 33 (#2)
(F) You used the syntax of a method call, but the slot filled by the
object reference or package name contains an expression that returns a
defined value which is neither an object reference nor a package name.
Something like this will reproduce the error:

$BADREF = 42;
process $BADREF 1,2,3;
$BADREF->process(1,2,3);

NOTE: Line 33 is the penultimate line below (starting with "$count")

--When I run the script, everything appears to work fine: by calling mwm.pl I get an html document to log in to, I am then taken to a window with three frames, I can set up new accounts, and all data is written to a subdirectory called "db." I can even send mail (/usr/lib/sendmail).

Here is what I hope is the relevant snippet from the 'inbox.pl' script:

#!/usr/bin/perl

use CGI qw(:standard);
use myPOP3;

if(param('tb')) {printToolbar();exit;}

checkLogin();

$account = param("a") || err();
$p_act = param("act") || "";

$p1 = '?';
$pwd = param("pwd") || $p1;

readPref('./db');

if(($PREF[2] eq $p1)) {
if($pwd eq $p1) { askPwd(); exit; }
else { $PREF[2] = $pwd; }
}

print "Content-type: text/html\n\n";
print "<html>\n";
printScript2();
print "<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0><fo
+nt face=\"times\" size=2>\n<form method=\"post\">\n";

deleteMsg($p_act) if ($p_act =~ /^del\|/);

$pop = myPOP3->new($PREF[0]) || print "Connection error.\n";
$count = $pop->login($PREF[1], $PREF[2]);
$scr = '<img src="img/scr.gif" width="8" height="16" border="0">';

I will reproduce more code if needed. Thank you very much.