Merge branch 'master' of https://Governor-Tarkin@bitbucket.org/Governor-Tarkin/swg...
[swg-src.git] / tools / find_tag_in_files.pl
blob02423c903d7ac73033ae2b8a0b12ba1861cbd073
1 $dir = shift @ARGV;
2 $lookIn = shift @ARGV;
3 $lookFor = shift @ARGV;
4 die "usage: directory extension_to_look_within tag_to_look_for_backwards\n" if (!defined($lookFor));
6 sub dodir
8 local($dir) = @_;
10 opendir(DIR, $dir) || die "opendir failed";
11 local(@dir) = readdir(DIR);
12 closedir(DIR);
14 foreach (@dir)
16 next if ($_ eq '.');
17 next if ($_ eq '..');
18 local($path) = $dir . '/' . $_;
20 if (-d $path)
22 &dodir($path);
24 else
26 push(@files, $path) if (/\.$lookIn$/)
30 &dodir($dir);
32 foreach $file (sort @files)
34 open(STRINGS, 'strings ' . $file . ' |');
35 while (<STRINGS>)
37 chomp;
38 print $file . "\t" . $_ . "\n" if (/$lookFor$/);