Subject: Re: [PATCH 2/5] gitweb: Do not use bareword filehandles

From: Petr Baudis <[email-masked]>
Date: Sun, 10 May 2009 09:50:53 +0200

On Sun, May 10, 2009 at 02:36:19AM +0200, Jakub Narebski wrote:
> The script was using bareword filehandles.  This is considered a bad
> practice so they have been changed to indirect filehandles.
> Changes touch git_get_project_ctags and mimetype_guess_file.
> 
> While at it rename local variable from $mime to $mimetype (in
> mimetype_guess_file) to better reflect its value (its contents).
> 
> Signed-off-by: Jakub Narebski <[email-masked]>
> ---
> Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles
> 
>   Write open my $fh, q{<}, $filename; instead of open FH, q{<}, $filename;.
> 
>   Using bareword symbols to refer to file handles is particularly evil
>   because they are global, and you have no idea if that symbol already
>   points to some other file handle. You can mitigate some of that risk by
>   'local'izing the symbol first, but that's pretty ugly. Since Perl 5.6, you
>   can use an undefined scalar variable as a lexical reference to an
>   anonymous filehandle.
> 
> See also Damian Conway's book "Perl Best Practices",
> chapter "10.1. Filehandles" (Don't use bareword filehandles.)
> 
> 
> This follows similar patch for git-send-email.perl by Bill Pemberton
> http://permalink.gmane.org/gmane.comp.version-control.git/117886
> 
> CC-ed Pasky, who is responsible for code in both cases...

Yeah, the book I learnt Perl from many years ago used bareword
filehandles (but it was an excellent textbook in most other aspects)
so this is a custom I have to work hard to evict. ;-)

Acked-by: Petr Baudis <[email-masked]>