in reply to Understanding variable scope in perl

So, BioBoy, here's what I propose you do ... take the entire program you've currently got, and whittle it down to as few a number of lines that you can which still exhibit the error.  Make sure you have use strict; and use warnings; at the top, of course.  In making the problem smaller, you may discover the root cause yourself.  But if not, at least it will attract the attention of more people willing to look at a managable task.

Make sure that what you submit really is the entire program, though.  It won't do any good if you're making data assignments (or lack thereof) which aren't included.  Your end goal here should be for anyone to run the code you submit on their own system, and see the same problem.

Good luck! ... and I'll be waiting to help you out more when you're ready ...

  • Comment on Re: Understanding variable scope in perl

Replies are listed 'Best First'.
Re^2: Understanding variable scope in perl
by BioBoy (Novice) on Sep 30, 2005 at 00:18 UTC
    Ahh, after looking at my code for an hour straight (literally, my eyes stayed on the screen on my PowerBook without moving), I found my elusive bug. Guess what it was? Yep, I had used an '<=" instead of a '<' in my while loop all this code is in, causing my code to overshoot my 'protein_matrix' and throw undefined errors. This little bug has caused me like 3 days........grrrrrr You guys are great though. Thanks. I've learned a lot of valuable debugging routes from this thread... By the way: Does perl have exception handling?

    **Special thanks to husker for introducing me to this online perl community**
      Ouch!!

      Now you see why you've got to show ALL the code, lest the words "(all this is actually in a while loop not posted)" come back to sting you!

      A final point -- don't ever submit code that you need reviewed by typing it in by hand (as I think you may have done to convert the loop variable to an actual value).  Always cut and paste!  Otherwise, even if the error is somewhere within the submission, you may "mentally fix the error" when you type it in, and nobody else will ever see it.

      Good luck!

      Howdy!

      Yep. Perl does exceptions.

      eval is the "try" part; checking $@ is the "catch". die is the "throw" bit.

      yours,
      Michael
        cool, thank. And liverpole: points well taken. thanks.