[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#2254: perl doesn't initialize variable to 0 or something



Without prejudice as to whether there's a bug in perl...

>In the following perl script, I must remove the comment "#" in line
>14 in order to get correct results.  This code worked in perl4 and
>should work in perl5 because variables "should" be automagically
>initialized to 0, no?

No, `undefined' is not the same as 0 in perl, though in some contexts
it does get automagically converted into 0 or "".  I find that messing
around with undefined things often leads to confusion.

The man page for perl emphasizes quite strongly that you should use
`perl -w'; it really does make life a lot easier!

--
Richard Kettlewell  richard@uk.geeks.org  http://www.elmail.co.uk/staff/richard/



Reply to: