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";
|