in reply to Sub call isn't returning values

Among other things tried:
--I've tried removing the $|=1;.
--I tried changing the order of &call_vars and print $CGI->header; (or Excel's mime type), but no luck.
--I've also tried rearranging where &call_vars appears (in the loop, outside the loop).
What do you think programming is? Alchemy? You just take some fragments of code, and shake them until it produces the right results?

Anyway, you seemed to have tried a lot, but did you print out the value of $spec_vars? Are you sure it contains what you think it contains?

Abigail

Replies are listed 'Best First'.
Re: Re: Sub call isn't returning values
by Lori713 (Pilgrim) on Mar 02, 2004 at 18:15 UTC
    As a beginner, I probably do treat programming as alchemy... especially when something isn't working, I try everything I can think of. I certainly want to make sure I do all I can before posting here (and I've learned to wear my asbestos suit!). ;-)

    Yes, I forgot to mention... I tried to print out spec_vars and it was empty after the second call to the page (which, of course, explains why variables later on in that second call are empty). However, when viewing the source at the end of the first call, the specs vars on the page have the appropriate data in them. I seem to be losing my data between the first call and the second call.

    Lori

      Lori713,
      Have you considered using the following code behind the button push:
      print $CGI->redirect( $CGI->self_url );
      I am not saying this is the most elegant solution, but it should keep the state of things between invocations.

      Cheers - L~R

      As a beginner, I probably do treat programming as alchemy... especially when something isn't working, I try everything I can think of.
      IMO, that's a very wrong thing to do. It won't teach you *anything*. If code works, or if you think it works just because it happens to produce the right output on a few test cases, it's just luck. It won't give you much insight.

      Yes, I forgot to mention... I tried to print out spec_vars and it was empty after the second call to the page (which, of course, explains why variables later on in that second call are empty).
      Well, that's a clear indication that your program isn't getting the data it's expecting. Not setting $|, calling the sub at a different time or cleaning the litter box aren't going to fix that.

      Abigail

        IMO, that's a very wrong thing to do. It won't teach you *anything*. If code works, or if you think it works just because it happens to produce the right output on a few test cases, it's just luck. It won't give you much insight.

        while i generally agree with that, i must say that it sometimes happens to me that i find myself trying out things until i get what i want. of course checking the docs before or after is crucial, but, to tell the truth, i learned a lot of cool perl features by trying out, just for the fun of it. (mostly that happened when playing golf or something, less often when i program production code)
        being curious and creative can help becoming a good programmer, IMHO.