Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 37905
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: amir.aharoni [...] mail.huji.ac.il
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.090
Fixed in: (no value)



Subject: do BLOCK while shouldn't be prohibited at ControlStructures::ProhibitPostfixControls
MIME-Version: 1.0
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Charset: utf8
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1216907463-23022-27"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 579
Download (untitled) / with headers
text/plain 579b
The construct my $count = 3; do { print "hello $count\n"; # always runs the first time } while (--$count); is a special case where a programmer always wants the BLOCK to run once before the condition is evaluated. The alternative is to write the BLOCK twice. (Correct me if i'm wrong.) It is different from the simple postfix while such as this: my $count = 3; print "hello\n" while (--$count); In the second case the postfix while indeed makes the code less readable. PBP doesn't mention the do { } while block. So, postfix while after a do { } block should be allowed.
Subject: postfix.pl
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1216907463-23022-26"
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/x-perl; name="postfix.pl"
Content-Disposition: inline; filename="postfix.pl"
Content-Transfer-Encoding: base64
Content-Length: 131
Download postfix.pl
text/x-perl 131b
#!/usr/local/bin/perl use strict; use warnings; my $countdown = 3; do { print "hello $countdown\n"; } while (--$countdown);
MIME-Version: 1.0
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Disposition: inline
Charset: utf8
Message-Id: <rt-3.6.HEAD-23017-1216908713-1330.37905-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 184
Download (untitled) / with headers
text/plain 184b
There is a separate policy "Don't use do-while loops" on PBP page 123. But this is an argument in favour of exempting do-while from this policy, since it's already covered by another.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-23017-1216908713-1330.37905-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Disposition: inline
Charset: utf8
References: <rt-3.6.HEAD-23017-1216908713-1330.37905-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-23017-1216909182-1638.37905-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: amir.aharoni [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 295
Download (untitled) / with headers
text/plain 295b
On Thu Jul 24 10:11:53 2008, EDAVIS wrote: Show quoted text
> There is a separate policy "Don't use do-while loops" on PBP page 123. > But this is an argument in favour of exempting do-while from this > policy, since it's already covered by another.
Missed it! I won't argue with PBP then. You may close this.
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00,SPF_PASS
In-Reply-To: <rt-3.6.HEAD-23017-1216908713-1330.37905-5-0 [...] rt.cpan.org>
References: <RT-Ticket-37905 [...] rt.cpan.org> <rt-3.6.HEAD-23017-1216908713-1330.37905-5-0 [...] rt.cpan.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 6383B4D8173 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 24 Jul 2008 11:10:46 -0400 (EDT)
Received: (qmail 17647 invoked from network); 24 Jul 2008 15:10:45 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 24 Jul 2008 15:10:45 -0000
Received: from pendrell.textdrive.com (HELO pendrell.textdrive.com) (207.7.108.149) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jul 2008 08:10:38 -0700
Received: from quaquaversal.local (ip131.fa1-0-1.occ.iinet.com [198.145.32.131]) by pendrell.textdrive.com (Postfix) with ESMTP id EC06CBB688 for <bug-Perl-Critic [...] rt.cpan.org>; Thu, 24 Jul 2008 15:10:33 +0000 (GMT)
Delivered-To: cpan-bug+Perl-Critic [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #37905] do BLOCK while shouldn't be prohibited at ControlStructures::ProhibitPostfixControls
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0
Return-Path: <perl [...] galumph.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-Perl-Critic [...] rt.cpan.org
Date: Thu, 24 Jul 2008 08:10:31 -0700
X-Spam-Level: *
Message-Id: <48889B67.204 [...] galumph.com>
To: bug-Perl-Critic [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Elliot Shank <perl [...] galumph.com>
RT-Message-ID: <rt-3.6.HEAD-23010-1216912280-690.37905-0-0 [...] rt.cpan.org>
Content-Length: 409
Download (untitled) / with headers
text/plain 409b
EDAVIS via RT wrote: Show quoted text
> There is a separate policy "Don't use do-while loops" on PBP page 123. > But this is an argument in favour of exempting do-while from this > policy, since it's already covered by another.
Actually, there isn't. (unless I've missed something.) However, this policy should be changed to look for this situation and change its explanation where this is found. Added to the todo list.
MIME-Version: 1.0
In-Reply-To: <rt-3.6.HEAD-23010-1216912280-690.37905-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.426 (Entity 5.426)
Content-Disposition: inline
Charset: utf8
References: <RT-Ticket-37905 [...] rt.cpan.org> <rt-3.6.HEAD-23017-1216908713-1330.37905-5-0 [...] rt.cpan.org> <48889B67.204 [...] galumph.com> <rt-3.6.HEAD-23010-1216912280-690.37905-0-0 [...] rt.cpan.org>
Message-Id: <rt-3.6.HEAD-23022-1216912425-1026.37905-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
From: amir.aharoni [...] gmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 442
Download (untitled) / with headers
text/plain 442b
On Thu Jul 24 11:11:20 2008, clonezone wrote: Show quoted text
> EDAVIS via RT wrote:
> > There is a separate policy "Don't use do-while loops" on PBP page
> 123.
> > But this is an argument in favour of exempting do-while from this > > policy, since it's already covered by another.
> > Actually, there isn't. (unless I've missed something.)
It's a best practice in the book, not in P::C. I checked it, it's on page 123 indeed, and it's rather convincing.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.