Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Too many arguments for main::

by seattlejohn (Deacon)
on Oct 29, 2002 at 22:50 UTC ( [id://208903]=note: print w/replies, xml ) Need Help??


in reply to Too many arguments for main::

Try removing the parens immediately following sub get_Origserver. What those are unintentionally doing is telling Perl that get_Origserver takes no arguments (because there's nothing between the parens), which is causing the error you see.

Check out the "prototypes" section in perldoc perlsub for more information on how this all works.

        $perlmonks{seattlejohn} = 'John Clyman';

Replies are listed 'Best First'.
Re: Re: Too many arguments for main::
by mnlight (Scribe) on Oct 31, 2002 at 17:04 UTC
    I have removed the parens and it works. But this is where it gets really confusing. Why does this code work? I make the same call at line 1047 and it compiles what is the difference between the two calls or sub routines.
    1024 LABEL: 1025 print "\nCREATE A DATABASE FOR EXISTING CLIENT OR COPY AN EXIS +TING DATABASE? \n"; 1026 print "Create Existing Client Database => 1\n"; 1027 print "Create New Client Database C=> 2\n"; 1028 print "Copy Existing Database => 3\n"; 1029 chomp(my $answer = lc(<STDIN>)); 1030 print "$answer\n"; 1031 if ($answer eq "1") { 1032 1033 my $cltlist = display_client(\$dbhTarget); 1034 if ($cltlist) { 1035 $cltlist = "Existing clients: \n" . $cltlist . 1036 "\nEnter Client ID: "; 1037 print $cltlist; 1038 chomp(my $cltid = <STDIN>); 1039 $params->put("Client.ID", $cltid); 1040 }#end if statement 1041 1042 } elsif ($answer eq "2") { 1043 1044 print "Please enter new client name: \n"; 1045 chomp(my $clt = <STDIN>); 1046 my $passwd = $params->get("Prod.Password"); 1047 my $cltid = add_client(\$dbhTarget, $clt, $passwd); 1048 $params->put("Client.ID", $cltid); 1049 1050 } elsif($answer eq "3"){ 1051 1052 print "Please enter name of the database to copy: \n"; 1053 chomp(my $Origdb = <STDIN>); 1054 my $Origserver = get_Origserver(\$dbhTarget, $Origdb); 1055 print "$Origserver is the server for the original db\n"; 1056 1057 } else{ 1058 1059 print "YOU MUST CHOOSE AN OPTION!!!!\n"; 1060 redo LABEL; 1061 1062 }#end else statement

    This works

    sub add_client() { print "******ADDING ROW TO CLIENT TABLE******\n"; print "I AM HERE\n"; my ($dbh, $clt, $prdpasswd) = @_; my $count = 1; my $cltid; my $sql = "select distinct CLT_ID from ENRMASTER..CLT order by CLT_ID" +; my $sth = $$dbh->prepare($sql) or $app->error($FATAL, "can't prepare SQL statement [ $sql ] : +:$DBI::errstr"); $sth->execute(); }
    This does not compile
    sub get_Origserver() { 919 920 print "******GETTING SERVER NAME OF THE DB BEING COPIED******\ +n"; 921 922 my ($dbh, $Origdb) = @_; 923 print "This is the db $dbh\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208903]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found