autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autoscan -v produces gigabytes of output - take 2


From: Jim Meyering
Subject: Re: autoscan -v produces gigabytes of output - take 2
Date: 02 Feb 2001 17:28:37 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.98

Pavel Roskin <address@hidden> wrote:
...
| +  if ($verbose)
| +    {
| +      my $word;
| +
| +      print "cfiles:", join(" ", @cfiles), "\n";
| +      print "makefiles:", join(" ", @makefiles), "\n";
| +      print "shfiles:", join(" ", @shfiles), "\n";
| +
| +      print "\nfunctions:\n";
| +      foreach $word (sort keys %functions)
| +     {
| +       print "$word: @{$functions{$word}}\n";
| +     }

Hi Pavel,

I find that code written with the declarations scoped as close as possible
to corresponding uses is easier to maintain.  Hence, I prefer to include
the declaration of the index in the line with each foreach statement
(that way you can't accidentally use the index variable outside the
loop context):

foreach my $word (sort keys %identifiers)
  {
    print "$word: @{$identifiers{$word}}\n";
  }

In fact, there's enough duplication in those 6 loops that
it's probably worthwhile to factor them.  How about this:

foreach my $class (qw (functions identifiers headers
                       makevars libraries programs))
  {
    print "\n$class:\n";
    my $h = eval "\\\%$class";
    foreach my $word (sort keys %$h)
      {
        print "$word: @{$h->{$word}}\n";
      }
  }

| +      print "\nidentifiers:\n";
| +      foreach $word (sort keys %identifiers)
| +     {
| +       print "$word: @{$identifiers{$word}}\n";
| +     }
| +
| +      print "\nheaders:\n";
| +      foreach $word (sort keys %headers)
| +     {
| +       print "$word: @{$headers{$word}}\n";
| +     }
| +
| +      print "\nmakevars:\n";
| +      foreach $word (sort keys %makevars)
| +     {
| +       print "$word: @{$makevars{$word}}\n";
| +     }
| +
| +      print "\nlibraries:\n";
| +      foreach $word (sort keys %libraries)
| +     {
| +       print "$word: @{$libraries{$word}}\n";
| +     }
| +
| +      print "\nprograms:\n";
| +      foreach $word (sort keys %programs)
| +     {
| +       print "$word: @{$programs{$word}}\n";
| +     }
| +    }
|  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]