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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jnareb@xxxxxxxxx>
> ---
> 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 <pasky@xxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]