git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/6] Remove bareword filehandles in git-send-email.perl

From
FGFrancis Galiegue <fge@one2team.com>
Date
May 3, 2009, 21:34 UTC
Message-ID
<200905032334.03286.fge@one2team.com>
In-Reply-To
<20090503205826.GF20468@coredump.intra.peff.net>
Le Sunday 03 May 2009 22:58:26 Jeff King, vous avez écrit :
Show 24 quoted lines
> On Wed, Apr 29, 2009 at 09:12:23AM -0400, Bill Pemberton wrote:
> > The script was using bareword filehandles.  This is considered a bad
> > practice so they have been changed to indirect filehandles.
>
> I think this is a real improvement; using indirect filehandles mean they
> get scoped properly, which can avoid errors (especially forgetting to
> close() them, which happens automagically when they go out of scope).
> Assuming, of course, that the scoping added by your change is correct,
> and doesn't close a handle during a loop that we may have wanted to keep
> open (I didn't check carefully).
>
> But in the patch itself:
> > -	open(C,">",$compose_filename)
> > +	open my $C,'>',$compose_filename
>
> There are actually two things happening here:
>
>   1. s/C/my $C/, which I think is good
>
>   2. losing the parentheses around open(). This is a style issue, but I
>      think we usually prefer the parenthesized form of most perl
>      builtins (and certainly in the absence of other information, it
>      should be left as-is).
>
And why not go the full way and using IO::File?
my $fh = new IO::File;
$fh->open("/the/file", O_RDONLY|...)
-- 
Francis Galiegue
fge@one2team.com
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
One2team
40 avenue Raymond Poincaré
75116 Paris
Previous: Jeff KingNext: H.Merijn Brand
Message 9 of 24 in “cleanups for git-send-email”
  1. 0/6 cleanups for git-send-emailBill Pemberton, Apr 29, 2009
  2. 1/6 Remove return undef from validate_patchBill Pemberton, Apr 29, 2009
  3. 2/6 Remove function prototypes from git-send-email.perlBill Pemberton, Apr 29, 2009
  4. 3/6 Remove return undef from ask()Bill Pemberton, Apr 29, 2009
  5. 4/6 Add explict return to end of subroutinesBill Pemberton, Apr 29, 2009
  6. 5/6 Remove mix of high and low-precedence booleansBill Pemberton, Apr 29, 2009
  7. 6/6 Remove bareword filehandles in git-send-email.perlBill Pemberton, Apr 29, 2009
  8. Jeff KingMay 3, 2009
  9. Francis GaliegueMay 3, 2009
  10. H.Merijn BrandMay 4, 2009
  11. Francis GaliegueMay 4, 2009
  12. H.Merijn BrandMay 4, 2009
  13. 5/6 Re: Remove mix of high and low-precedence booleansNicolas Sebrecht, Apr 29, 2009
  14. Bill PembertonApr 29, 2009
  15. Jeff KingMay 3, 2009
  16. Jeff KingMay 3, 2009
  17. Jay SoffianMay 4, 2009
  18. Jeff KingMay 3, 2009
  19. Jeff KingMay 3, 2009
  20. Junio C HamanoApr 29, 2009
  21. Bill PembertonApr 29, 2009
  22. Junio C HamanoApr 29, 2009
  23. 0/6 Re: cleanups for git-send-emailNicolas Sebrecht, Apr 29, 2009
  24. Andreas EricssonApr 30, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.