ednit
12-15-2005, 06:35 PM
I have a script that gives me a undefined subroutine error:
#!/usr/bin/perl
require "main.pm";
use CGI::Carp qw(fatalsToBrowser);
use CGI;
$in = new CGI;
$userid = $in->param('userid');
$do = $in->param('do');
$catname = $in->param('catname');
$goto = $in->param('goto');
$description = $in->param('description');
$catid = $in->param('catid');
$ncname = $in->param('ncname');
$cdisp = $in->param('cdisp');
print "content-type: text/html\n\n";
if ($do eq "viewbylinks") {&udDB_vblinks;}
if ($do eq "viewbycategory") {&udDB_vbcategory;}
if ($do eq "") {&main;}
if ($do eq "ac") {&addcat;}
if ($do eq "AC2DB") {&AC2db;}
if ($do eq "ADDLINK") {&addlink;}
if ($do eq "ec") {&editcatform;}
if ($do eq "editcatc") {&editcatc;}
if ($do eq "delcat") {&delcatconfirm;}
if ($do eq "updatecname") {&updatecname;}
if ($do eq "nodcat") {&nodcat;}
if ($do eq "addlink") {&addalink;}
if ($do eq "yesdcat") {&dcatyes;}
##################
##### MAIN PAGE #####
##################
sub main {
$session_cookie = $in->cookie('webgo2_tracksession') ;
if (!$session_cookie) { &new_session; exit;}
else {
$userid = $session_cookie;
}
&opendb;
&users($userid);
if ($u_verified eq "no") {&closedb; &reverifyme; exit;}
$le = $dbh->prepare("select view from users_trackview where userid='$userid'");
$le->execute();
$ss = $le->fetchrow_hashref();
$thisusersview = $ss->('view');
if ($thisusersview eq "") {&closedb;
&header;
print qq~
Please choose how you want to view your tracking links:<br>
<a href="?do=viewbylinks">View By Links</a> (new system) <a href="?do=viewbycategory">View By Category</a> (old system)<br><br>
You may change your viewing preferences on your <a href="edit.cgi">Account Settings</a> page at any time. ~; &footer; exit; }
However, I do not get the error when I remove last part of it:
$le = $dbh->prepare("select view from users_trackview where userid='$userid'");
$le->execute();
$ss = $le->fetchrow_hashref();
$thisusersview = $ss->('view');
if ($thisusersview eq "") {&closedb;
&header;
print qq~
Please choose how you want to view your tracking links:<br>
<a href="?do=viewbylinks">View By Links</a> (new system) <a href="?do=viewbycategory">View By Category</a> (old system)<br><br>
You may change your viewing preferences on your <a href="edit.cgi">Account Settings</a> page at any time. ~; &footer; exit; }
The code is for a link tracking service where tracking links either viewed by category or by only the tracking links. In the code that seems to be messing it up the script is checking the preferences datbase, and if the user has not set their preferences the members are required to choose one option.
This is the error I get:
Undefined subroutine &main:: called at track.cgi line 54.
Line 54 is this one: $thisusersview = $ss->('view');
If anyone has any suggestions, I would appreciate it. I can also explain anything if needed.
Thanks.
#!/usr/bin/perl
require "main.pm";
use CGI::Carp qw(fatalsToBrowser);
use CGI;
$in = new CGI;
$userid = $in->param('userid');
$do = $in->param('do');
$catname = $in->param('catname');
$goto = $in->param('goto');
$description = $in->param('description');
$catid = $in->param('catid');
$ncname = $in->param('ncname');
$cdisp = $in->param('cdisp');
print "content-type: text/html\n\n";
if ($do eq "viewbylinks") {&udDB_vblinks;}
if ($do eq "viewbycategory") {&udDB_vbcategory;}
if ($do eq "") {&main;}
if ($do eq "ac") {&addcat;}
if ($do eq "AC2DB") {&AC2db;}
if ($do eq "ADDLINK") {&addlink;}
if ($do eq "ec") {&editcatform;}
if ($do eq "editcatc") {&editcatc;}
if ($do eq "delcat") {&delcatconfirm;}
if ($do eq "updatecname") {&updatecname;}
if ($do eq "nodcat") {&nodcat;}
if ($do eq "addlink") {&addalink;}
if ($do eq "yesdcat") {&dcatyes;}
##################
##### MAIN PAGE #####
##################
sub main {
$session_cookie = $in->cookie('webgo2_tracksession') ;
if (!$session_cookie) { &new_session; exit;}
else {
$userid = $session_cookie;
}
&opendb;
&users($userid);
if ($u_verified eq "no") {&closedb; &reverifyme; exit;}
$le = $dbh->prepare("select view from users_trackview where userid='$userid'");
$le->execute();
$ss = $le->fetchrow_hashref();
$thisusersview = $ss->('view');
if ($thisusersview eq "") {&closedb;
&header;
print qq~
Please choose how you want to view your tracking links:<br>
<a href="?do=viewbylinks">View By Links</a> (new system) <a href="?do=viewbycategory">View By Category</a> (old system)<br><br>
You may change your viewing preferences on your <a href="edit.cgi">Account Settings</a> page at any time. ~; &footer; exit; }
However, I do not get the error when I remove last part of it:
$le = $dbh->prepare("select view from users_trackview where userid='$userid'");
$le->execute();
$ss = $le->fetchrow_hashref();
$thisusersview = $ss->('view');
if ($thisusersview eq "") {&closedb;
&header;
print qq~
Please choose how you want to view your tracking links:<br>
<a href="?do=viewbylinks">View By Links</a> (new system) <a href="?do=viewbycategory">View By Category</a> (old system)<br><br>
You may change your viewing preferences on your <a href="edit.cgi">Account Settings</a> page at any time. ~; &footer; exit; }
The code is for a link tracking service where tracking links either viewed by category or by only the tracking links. In the code that seems to be messing it up the script is checking the preferences datbase, and if the user has not set their preferences the members are required to choose one option.
This is the error I get:
Undefined subroutine &main:: called at track.cgi line 54.
Line 54 is this one: $thisusersview = $ss->('view');
If anyone has any suggestions, I would appreciate it. I can also explain anything if needed.
Thanks.