Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cspYa-0001WY-L7 for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 11:45:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cspYa-0005Cz-6A for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Mar 2017 11:45:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cspYZ-0005Cp-3m for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 11:44:59 +0000 Received: from ping.uio.no ([2001:700:100:570::196]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cspYV-0005Ec-Ud for pgsql-hackers@postgresql.org; Tue, 28 Mar 2017 11:44:57 +0000 Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1cspYR-0004CD-JA; Tue, 28 Mar 2017 13:44:53 +0200 Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.84_2) (envelope-from ) id 1cspYR-0004eE-7p; Tue, 28 Mar 2017 13:44:51 +0200 From: ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) To: Andrew Dunstan Cc: Tom Lane , Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: [COMMITTERS] pgsql: Clean up Perl code according to perlcritic References: <14575.1490652977@sss.pgh.pa.us> <4193.1490662733@sss.pgh.pa.us> <837eb7fd-55bb-1dc6-4727-ca472b0aaaf6@2ndQuadrant.com> Mail-Copies-To: nobody Date: Tue, 28 Mar 2017 12:44:51 +0100 In-Reply-To: <837eb7fd-55bb-1dc6-4727-ca472b0aaaf6@2ndQuadrant.com> (Andrew Dunstan's message of "Tue, 28 Mar 2017 07:30:22 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Exiscan-Spam-Score: -3.7 (---) X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Andrew Dunstan writes: > On 03/28/2017 05:23 AM, Dagfinn Ilmari Mannsåker wrote: >> + @opts = grep { !/\$\(/ && /^--/ } >> + map { (my $x = $_) =~ s/\Q$(top_builddir)\E/\"$topdir\"/; $x;} >> + split(/\s+/, $1); >> > > The use of this lexical $x variable seems entirely pointless and > obfuscatory. If perlcritic doesn't like it without then that's another > black mark against it IMNSHO. The lexical copy is not strictly necessary in this case, because the values we're mapping over are mutable temporaries returned by split(). An alternative form would be: @opts = grep { !/\$\(/ && /^--/ } map { s/\Q$(top_builddir)\E/\"$topdir\"/; $_ } split(/\s+/, $1); Perlcritic complains about that, though: src/tools/msvc/vcregress.pl: Don't modify $_ in list functions at line 524, column 4. See page 114 of PBP. (Severity: 5) This for two reasons: 1) If we were mapping over an array varible it would modify the original values in-place (since $_ is an alias, not a copy). 2) If the list were to contain read-only items it'd throw a "Modification of a read-only value attempted" exception. The /r modifier was introduced in perl 5.14 exactly for this reason: it makes the substitution non-destructive and returns the modified string instead. However, we still support perls as ancient as 5.8, so we can't use that. - ilmari -- - Twitter seems more influential [than blogs] in the 'gets reported in the mainstream press' sense at least. - Matt McLeod - That'd be because the content of a tweet is easier to condense down to a mainstream media article. - Calle Dybedahl -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers