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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: ikobo.pl return to script
by Errto (Vicar) on Feb 04, 2005 at 23:46 UTC

    Well, I have free time on my hands so against my better judgement I'm going to take a crack at this. But first I would like to make some suggestions that will help you both in your code and in getting help here at Perl Monks.

    • First, you must begin by explaining, in one paragraph or less, what your code does. I have no idea what the actual purpose of your site is, what ikobo.com is, etc.
    • Second, you need to understand the correct amount of code to post. Posting only the first two lines you showed are not good enough because we have no idea what the context for them is. But posting your entire program is also not that helpful because it's too much code and we don't know where the problem is. So you need to put up some initial effort, not just by searching the web and posting in different forums, but by reducing your code to a small test case that illustrates the problem and then posting that.
    • Third, do not be rude or impatient. Some of us, including myself, have the good fortune of being paid to write code, but no one is paid to post to Perl Monks. So have some patience and some respect.
    • Fourth, begin every program you write with use strict and use warnings unless you know you don't need to. Put these at the very top of your code. Also, when debugging CGI, read your log files constantly.
    • Fifth, use CGI or one of its replacements such as CGI::Simple. I don't see any obvious errors in your form-parsing code, but it adds clutter and obscures what you are really trying to accomplish.
    • Sixth, avoid use of use vars and local unless you know you need them. And try only to declare variables in the scope where they're actually used. Declaring all these variables as globals or file-scoped lexicals makes debugging harder.
    • Finally, since you are outputting large amounts of HTML, it will improve your code's clarity if you use a templating system such as HTML::Template or the Template Toolkit. This is a matter of taste, but again it helps with debugging and also forces you to think about the actual data structures that are needed in your HTML output.

    I am going to start by looking at the last script you listed and assume, since you didn't say so, that this is the script that runs when I go to the URL you posted. The first problem is that you are calling

    &read_item_file($form{'category'},$form{'item'});
    at the very beginning of your program before you have populated the hash %form with any data. Hence the variables $category and $item will always be empty.

    Second, you post the code of a function called postal_login without giving any indication of where it is called from. So I have no idea what is wrong with that code. But since you are referring to $ENV{SCRIPT_NAME} in all of the links you generate, I assume it is simply whatever code is processing the form. That code calls a lot of other subroutines that you have not explained what they do, but as it is the code in postal_login looks ok to me if the %form hash is populated when you call it.

    Third, if you look at the code you posted first, the ikopo.pl script, you will see that it does nothing other than write to a local file and then print out the string "RESP=OK" with a content type of text/plain. You sound like you expect it to "return to mt script" but since you don't say how you are calling it, we can't help you with that part. If you call it from your other CGI using LWP this might be one way.

      I canīt find anything rude or impatient in efrets postings.

      holli, regexed monk
        Maybe I'm thinking of an earlier thread.
Re: ikobo.pl return to script
by bgreenlee (Friar) on Feb 04, 2005 at 21:10 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: ikobo.pl return to script
by Mr. Muskrat (Canon) on Feb 05, 2005 at 02:54 UTC
    ...the following line of code creates a "Buy Now" link and processes the payment to the 3rd party sellers account
    print "<P><A HREF=$ENV{'SCRIPT_NAME'}?action=buynow&category=&item=$fo +rm{'item'}>Buy Now</A></FONT>" if (($buyit ne "") & ($bid < $buyit));

    You're partially right. It does create the "Buy Now" link but the payment processing doesn't happen at this point. It potentially would if someone were to click that link though.

    ...the following line of code processes the ikobo transaction to my account
    print " - <A HREF=$ENV{'SCRIPT_NAME'}\?action=paypal_login\&ALIAS=$for +m{'ALIAS'}\&balance=$balance> PayPal </A>" if ($config{'allowpaypal'} + != 0);

    No it doesn't. It conditionally prints a hyperlink which if clicked could potentially do the processing.

    Ask the provider of the script for help. I've seen enough to know better than to look any further through the code.