Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.57 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3.  
  4. my %classes;
  5.  
  6. if(@ARGV == 0) {
  7.   die "Please pass at least one jar file through the command line.\n";
  8. }
  9.  
  10. foreach my $file (@ARGV) {
  11.   print "Reading $file\n";
  12.   open my $jar, "jar tf $file|" or die "Cannot open jar: $!\n";
  13.   while(<$jar>) {
  14.     chomp;
  15.     next if (!/^.*\.class$/);
  16.     push(@{$classes{$_}}, $file);
  17.   }
  18. }
  19. foreach my $class (sort keys %classes) {
  20.   if(@{$classes{$class}} > 1) {
  21.     my $line = "$class =>";
  22.     foreach my $file (@{$classes{$class}}) {
  23.       $line .= " $file";
  24.     }
  25.     print "$line\n";
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement