Files
swg-src/tools/find_extension_in_files.pl
2015-08-01 22:04:39 -05:00

41 lines
669 B
Perl
Executable File

$dir = shift @ARGV;
$lookIn = shift @ARGV;
$lookFor = shift @ARGV;
die "usage: directory extension_to_look_within extension_to_look_for\n" if (!defined($lookFor));
sub dodir
{
local($dir) = @_;
opendir(DIR, $dir) || die "opendir failed";
local(@dir) = readdir(DIR);
closedir(DIR);
foreach (@dir)
{
next if ($_ eq '.');
next if ($_ eq '..');
local($path) = $dir . '/' . $_;
if (-d $path)
{
&dodir($path);
}
else
{
push(@files, $path) if (/\.$lookIn$/)
}
}
}
&dodir($dir);
foreach $file (sort @files)
{
open(STRINGS, 'strings ' . $file . ' |');
while (<STRINGS>)
{
chomp;
print $file . "\t" . $_ . "\n" if (/\.$lookFor$/);
}
}