in reply to Re: Identify Unused and Uninitialised variables.
in thread Identify Unused and Uninitialised variables.
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
|
|---|