forked from agunchan/autoproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_string.pl
executable file
·27 lines (21 loc) · 853 Bytes
/
remove_string.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl -w
use strict;
my ($file, $string) = @ARGV;
opendir(local *DIR, "chrome/locale") or die "Could not open directory chrome/locale";
my @locales = sort {$a cmp $b} grep {!/[^\w\-]/} readdir(DIR);
closedir(DIR);
foreach my $locale (@locales) {
open(local *FILE, "chrome/locale/$locale/$file") or die "Could not open file chrome/locale/$locale/$file";
local $/;
my $data = <FILE>;
close(FILE);
if ($file =~ /\.dtd$/) {
$data =~ s/<!ENTITY\s $string\s "[^"]*">\s*//gs or (warn "String $string not found in file chrome/locale/$locale/$file" && next);
}
else {
$data =~ s/^$string=.*\n//gm or (warn "String $string not found in file chrome/locale/$locale/$file" && next);
}
open(FILE, ">chrome/locale/$locale/$file") or die "Could not write file chrome/locale/$locale/$file";
print FILE $data;
close(FILE);
}