in reply to uninitalised value in numeric

That isn't an error per say.. It's a warning. What it's complaining about the > test because at the time $counter has not yet been initialized. Note that being declared and being initialized are two different things. Perl will automatically assume, if it hasn't yet been initialized, that its value is 0 or an empty string depending on where you're using it for the first time.

In short, if the automatically-set-to-zero behavior is acceptable, you don't need to give the warning any thought. But if at the time that warning is produced, you're expecting $counter to have a value, you should look at your code and see where you aren't assigning something to it where you should.

Once bread becomes toast, it can never be bread again.

Replies are listed 'Best First'.
Re: Re: uninitalised value in numeric
by jmcnamara (Monsignor) on May 22, 2002 at 12:41 UTC

    It's complaining about the > test because at the time $counter has not yet been initialized.

    It is initialised:     my $counter=0;

    You're expecting $counter to have a value, you should look at your code and see where you aren't assigning something to it where you should.

    The $counter will always have a value, it is initialised and incremented, there is no subsequent assignment.

    --
    John.