kiat has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I'm quite used to declaring variables as follows:

my ($title, $page, $chapter);
That is, without initialising them with default values.

I also find it quite common in other people's code that I've come across.

I'm wondering, after reading about variables being set to old values under mod_perl, if it might be better in general to initialise each and every variable. So, instead of the above, we now have:

my $title = ''; my $page = 0; my $chapter = 0;
It's more work definitely but it generally makes the code more readable (for instance, if I've no idea what 'page' means, I at least know the variable $page is going to be used for some numerical value). There're probably also some gains in performance as the interpreter doesn't have to make guesses about those values.

Is it merely a preference thing? Or is one method better than the other?

I look forward to reading your views. Many thanks in advance :)

update: It's been very enlightening reading your comments on the node. It seems not initialising the variables is the normal thing to do in most circumstances. Thanks once again for your sharing :)