Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Missing $ on loop variable at measurements2.pl line 69.

by davorg (Chancellor)
on Sep 08, 2006 at 11:59 UTC ( [id://571940]=note: print w/replies, xml ) Need Help??


in reply to Missing $ on loop variable at measurements2.pl line 69.

I expect that the line in question is this one:

for my ($counter=0;$counter<9;$counter++)

You're making two mistakes there. Firstly you're confusing "for" loops with "foreach" loops. The "for" loop syntax doesn't require a loop variable. And secondly, you have the "my" that is going to declare a loop variable, but you don't actually declare the variable.

You probably meant to write:

for ($counter=0;$counter<9;$counter++)

But that's probably easier to understand if it's written as:

foreach my $counter (0 .. 8)

It's worth pointing out that the perldiag man page has complete descriptions of all Perl diagnostic messages.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: Missing $ on loop variable at measurements2.pl line 69.
by Yoda_Oz (Sexton) on Sep 08, 2006 at 12:37 UTC
    sorted thanks!
    however...
    now i get:
    Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in int at measurements2.pl line 42. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in addition (+) at measurements2.pl line 60 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in division (/) at measurements2.pl line 63 +. Use of uninitialized value in addition (+) at measurements2.pl line 60 +.

      That means that in various calculations (on the indicated lines) you are trying to use a value from a variable that you haven't previously put a value in. This is often indicative of a problem in the logic of your program.

      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

      A reply falls below the community's threshold of quality. You may see it by logging in.
      this happens because you haven't assigned any value to $person_count (only to $vision_total).
      try changing my ($vision_total,$person_count)=0; to my ($vision_total,$person_count)=(0,0);


      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "one who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever."

      mk at rio dot pm dot org
        thank you.. i just learnt a lot from your post!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://571940]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2024-04-24 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found