From: Eric Sunshine Date: Mon, 11 May 2015 06:59:21 GMT Subject: Re: [PATCH v5 6/6] cmd-list.perl: ignore all lines until [commands] Message-ID: In-Reply-To: <1431191856-10949-7-git-send-email-sebastien.guimmara@gmail.com> On Sat, May 9, 2015 at 1:17 PM, Sébastien Guimmara wrote: > command-list.txt contains a [common] block that should be ignored > by the Documentation checker cmd-list.perl. > > Filter out this block before the actual processing of the command list. > > Signed-off-by: Sébastien Guimmara > --- > diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl > index 04f9977..d581378 100755 > --- a/Documentation/cmd-list.perl > +++ b/Documentation/cmd-list.perl > @@ -38,8 +38,14 @@ sub format_one { > } > } > > +my @filtered = (); > +while (<>) > +{ Style: while (<>) { > + push (@filtered, $_) unless 1../^\[commands\]/; > +} Why collect the lines into @filtered when you could instead merely skip the unwanted ones outright? while (<>) { last if /^\[commands\]/; } And, then you don't need to touch the following 'for' loop at all. > my %cmds = (); > -for (sort <>) { > +for (sort @filtered) { > next if /^#/; > > chomp; > -- > 2.4.0