in reply to Perl Style: Is initializing variables considered taboo?
Since I started using Perl I've always initialized my variables, many times with undef, but I've seen a lot of CPAN code that doesn't. Maybe it's considered wasteful or uncool?I usually "declare" my variables on first use - or phrased differently, as soon as I "declare" my variables, I use them. Which, for scalar variables, usually means they immediately get a value (unless I just want their reference). But if they get a value, it usually isn't "undef". I find both
andmy $x;
to be pretty wasteful. I prefermy $y = undef;
my $z = shift; my $w = $hash{foo}; my ($v, $u) = /pattern/g; while (my ($s, $t) = each %hash) {...} while (my $r = <>) {...} ...
|
|---|