Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Newbie Errors

by Sherlock (Deacon)
on May 30, 2001 at 07:28 UTC ( #84160=note: print w/replies, xml ) Need Help??

in reply to Newbie Errors - Uninitialized Values

If you look closely at your script, you'll notice that you read 1 line from your file (as expected). When you leave the loop to read from your file, $foo = 1. If you then look at each of your for loops below, they run from 0 to (and including) $max_vectors, which is equal to $foo, or 1. Therefore, those loops will each run twice, the first time, performing operations on $vectorA[0], $angleA[0], etc. and the next time on $vectorA[1], $angleA[1], etc. But since your loop to read in from file only executed once, only the values in $vectorA[0], $angleA[0], ... , are initialized. It's the second time through those for loops that is causing the uninitialized variable errors.

You can solve this problem (only to see that it works) by adding this to the top of the script:
# Initialize the variables that are causing problems $vectorA[1] = 0; $angleA[1] = 0; $vectorB[1] = 0; $angleB[1] = 0;
I really doubt that this is what you want to do to initialize these variables - it's simply what I did to test my hypothesis of what was wrong.

By the way, I added use strict; to the top of this script and got a whole bunch of errors. You might want to add that in and clean up a little before this script gets too unruly to deal with.

Good Luck,
- Sherlock

Skepticism is the source of knowledge as much as knowledge is the source of skepticism.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://84160]
[Tanktalus]: curious, then, why the reader works :)
[Tanktalus]: or posting the last hour of cb... well, maybe I should double check that first :)
[Tanktalus]: yup, it's working. :)
[choroba]: https://github. com/choroba/pm-cb/ commit/7b57f513596 7bf8a29d74f1c307de 9a76894cdcf
[choroba]: Also, a thread here on PM mentioned that one of or should now work
[choroba]: Tidings
[Tanktalus]: So, I can log in, I can update last hour of cb, I can read the cb, I just can't post a message to it :(

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2018-07-15 21:32 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (326 votes). Check out past polls.