Next Program Repair Shop 21

Repeated expressions

     644      foreach $md5sum (keys %file_name_by_md5sum)
     645      {
     646        push @md5_LoL , [ @{$file_name_by_md5sum{$md5sum}} ]
     647            if ( scalar  (@{$file_name_by_md5sum{$md5sum}}) > 1);
     648            # do NOT push single file lists, there's nothing to match!
     649  
     650  print STDERR "jsjvv: md5sum found " .
     651            scalar  (@{$file_name_by_md5sum{$md5sum}}) . " matches\n"
     652      if ($verbose1) && ( scalar  (@{$file_name_by_md5sum{$md5sum}}) > 1);
     653      }

k
* In this case, all we need is to assign @{$file_name_by_md5sum{$md5sum}} to a temporary variable:

      foreach $md5sum (keys %file_name_by_md5sum)
      {
        my @files = @{$file_name_by_md5sum{$md5sum}};
        push @md5_LoL , \@files
            if ( scalar  (@files) > 1);
            # do NOT push single file lists, there's nothing to match!
        print STDERR "jsjvv: md5sum found " .
            scalar  (@files) . " matches\n"
      if ($verbose1) && ( scalar  (@filesg) > 1);
      }

Repeated Code is a Mistake


Next Copyright © 2006 M. J. Dominus