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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.