in reply to Re: Identify Unused and Uninitialised variables.
in thread Identify Unused and Uninitialised variables.

I think the op may have been thinking of "useless variables" as mentioned in your sig. I often go back over my code and find that as it developed uncessary variables (even subs and objects) are left hanging around.

One way of reducing this is to declare vars as close too where the vars are used as you can, and in the smallest scope possible. Even to the extent of creating a scope to put them in. When reviewing/refactoring you can see that the whole block (with its vars) can come out.

my $html; { # $filename and $fh only used here # and they won't conflict with anything else my $filename = q{some/file.html}; open my $fh, q{<}, $filename or die qq{cant open $filename: $!\n}; $html = do{local $/;<$fh>}; } # any previous $filename and $fh remain unharmed