in reply to Re^3: Missing $ on loop variable at measurements2.pl line 69.
in thread Missing $ on loop variable at measurements2.pl line 69.

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^4: Missing $ on loop variable at measurements2.pl line 69.

Replies are listed 'Best First'.
Re^5: Missing $ on loop variable at measurements2.pl line 69.
by Nevtlathiel (Friar) on Sep 08, 2006 at 13:40 UTC
    my $number; #at the moment it's uninitialized - it exists, but it +doesn't have a value $number++; #this will print an uninitialized variable warning $number = 6; #now we're getting somewhere! $number++; #this is fine :)

    ----------
    "Write a wise saying and your name will live forever." - Anonymous

      Actaully, $var++; doesn't give uninitialized warnings. $var = $var + 1; would.
Re^5: Missing $ on loop variable at measurements2.pl line 69.
by davorg (Chancellor) on Sep 08, 2006 at 13:41 UTC

    You give a variable a value by using the '=' operator.

    So the steps you need to go through are:

    • Identify which variables are being used before they have been given a value
    • Decide which value it would be appropriate to give them (often zero or the empty string)
    • Use the assignment operator to assign the relevant operator to the correct variable

    I hope that makes sense. I don't think I can break it down any more without just writing the code for you - and I hope you wouldn't want that.

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

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