powerhouse has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting an error returned for this subroutine...

sub Go_Check_ID { my $id_2_check = shift; my $in_there_already = 0; my $is_completed = 0; my $is_failed = 0; my $is_denied = 0; my $is_pending = 0; my $which_db = ""; if ($is_subscrb) { $which_db = "subscrb"; } else { $which_db = "nonsubscrb"; } my $dbh = MyMODULE::NameConnect(); $sth = $dbh->prepare (qq{ SELECT * FROM $which_db WHERE id = ? }); $sth->execute($id_2_check); $row = $sth->fetchrow_hashref(); $sth->finish(); if ($row && $row->{id} =~ /^$id_2_check$/) { $in_there_already++ if ($row->{payment_status} =~ /^Pending$/i) { # Line 311 $is_pending++; } elsif ($row->{payment_status} =~ /^Failed$/i) { $is_failed++; } elsif ($row->{payment_status} =~ /^Denied$/i) { $is_denied++; } elsif ($row->{payment_status} =~ /^Completed$/i) { $is_completed++; } } if ($in_there_already == 0) { return("JUST_ADD_IT"); } elsif($in_there_already == 1 && $is_completed == 0 && $is_failed + == 0 && $is_denied == 0 && $is_pending == 1) { return("JUST_UPDATE_IT"); } elsif ($in_there_already == 1 && ($is_completed == 1 || $is_fail +ed == 1 || $is_denied == 1)) { return 0; } } # Line 329


That is the whole subroutine.

Here is the error:
I marked which lines those are in the subroutine.

I've added this line to it:


It has not given me any more help though. I do have -w defined and I added Strict and cleaned up the code.

Still I am getting this error. Plus I'm getting a whole bunch of these "warnings" I guess you'd call them.
Warnings:

I don't know why those are there. I assume it's because I have a if/then statement where if one statement is true it will use that sites "module". The modules are identical, the ONLY difference is the usernames/passwords for the mysql connections.

I'd appreciate any advice anyone might have.

thx,
Richard

Replies are listed 'Best First'.
Re: Error in Syntax...
by Coruscate (Sexton) on Feb 09, 2003 at 00:07 UTC

    Line 310 is missing a semi-colon to finish off the statement and is probably the reason that line 329 is causing a problem as well. For the MyModule.pm errors, you are declaring sub expires_1 twice.


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.

      Geeze, thank you! I must have looked over that about 10 times, character by character, and did not see that. Thanks for spotting that for me. :o)

      Strange that all I did was ask a question, and people downvoted it ;o) Wow, I guess it does not pay to ask questions ;o)

      Anyways, I have another...

      With regards the part that says "redefined", it did not do that until I added this:
      BEGIN { if (defined($in{bus}) && $in{bus} =~ /frhb$/i) { use MyModule::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb2$/i) { use MyModule2::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb3$/i) { use MyModule3::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb4$/i) { use MyModule4::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb5$/i) { use MyModule5::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb6$/i) { use MyModule6::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb7$/i) { use MyModule7::PckgName; } elsif (defined($in{bus}) && $in{bus} =~ /frhb8$/i) { use MyModule8::PckgName; } }

      Of course as usual for security, I changed the module names, since this is on a shared server. I also push the location to @inc at the top of the script.

      Why would it do that if it is actually NOT executing the "use" statement, since only one can be true?

      The actual modules are identical, like I said earlier, they are only different with regards to the username and password for MySQL access. Each different module is for a different site, all on the same server.

      I'd appreciate any thoughts on that.

      thx,
      Richard

        In your original post, you say that the code within the modules is the exact same except for the mysql authentication. That sets off red alerts all around within my head. What happens if you need to change the code for one or more of the subroutines within these modules? You'll have to go tyhrough every single one, making the changes. My question to you is why you are using a separate module if all that differs is usernames/passwords? Use only one module. When you load it, either pass the username and password pair to the module to make the connection, or make the module retrieve this information itself, based on a parameter passed to it. Please please please don't copy the same module to a separate file just to change two variables. Find a way to pass the authentication information to the module. This will narrow everything down to one module, which will make readability, coding-friendly, and maintainable/manageable code. Besides, I bet that doing so will eliminate or narrow down the problem with the double-declared subroutine.


        If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.

Re: Error in Syntax...
by pfaut (Priest) on Feb 09, 2003 at 00:18 UTC

    From a quick look over the code, I don't see an opening brace for the closing brace on line 329.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
      That's the closing brace for the whole sub.