Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.19 KB | None | 0 0
  1. #!/usr/bin/perl
  2. my $basedir = "/Users/chipzz/Interface";
  3.  
  4. our %string_locations;
  5. while (<>)
  6. {
  7.         chomp;
  8.         $string_locations{$_} = {};
  9. }
  10. my $regex_string = join "|", keys %string_locations;
  11. my $re = qr/\b($regex_string)\b/;
  12.  
  13. sub ggg
  14. {
  15.         my ($base, $sub) = @_;
  16.         my $dir = "$base/$sub";
  17.         opendir (my $dh, $dir) || die "Can't open $dir\n";
  18.         while (readdir $dh)
  19.         {
  20.                 next if (/^\.\.?$/);
  21.                 ggg($dir, $_) if (-d "$dir/$_");
  22.                 if (/\.(xml|lua)$/)
  23.                 {
  24.                         open FILE, "$dir/$_";
  25.                         foreach my $match (grep $_ =~ $re, (<FILE>))
  26.                         {
  27.                                 $match =~ $re;
  28.                                 @{$string_locations{$1}}{$subdir} = 1;
  29.                         }
  30.                         close FILE;
  31.                 }
  32.         }
  33.         closedir $dh;
  34. }
  35.  
  36. foreach our $subdir (qw(FrameXML GlueXML SharedXML AddOns))
  37. {
  38.         ggg($basedir, $subdir);
  39. }
  40.  
  41. foreach my $string (keys %string_locations)
  42. {
  43.         print "$string\t";
  44.         print join "\t", sort keys %{$string_locations{$string}};
  45.         print "\n";
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement