From: Junio C Hamano Date: Fri, 06 Jan 2006 22:38:25 GMT Subject: Re: [PATCH] git-mv.perl: use stderr for error output and cleanup Message-ID: <7vek3lq8wu.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <81b0412b0601050349s6bec1a36jc410fd315fbbc4c@mail.gmail.com> Alex Riesen writes: > It is cleaned up in the "Perl' meaning" of process: trivial loops > replaced with map{} I agree with dies and warns, but I am slightly negative about this one. > - foreach my $fileName (@deletedfiles) { > - print H "$fileName\0"; > - } > + print H map {"$_\0"} @deletedfiles; Although there is always one more way to do the same thing in Perl, and there are good idioms that make well written Perl programs very compact and clear, I tend to value readability for (competent) programmers whose native language happens to be something other than Perl. I think using map{} to build a list to be printed without inter-element spaces is far less intuitive than how the code was originally written for non Perl readers. Using join("\0", @df) might be easier to read but you would then need terminating NUL, and either one of the following are worse: do { local ($") = "\0"; print "@deletedfiles\0" } # this one is buggy do { local ($\) = "\0"; print for (@deletedfiles); } # impossible to read So I'd prefer not touching for (@df) { print H "$_\n" } loops.