Something
public text v1 · immutable#!/usr/bin/perl
my $ACL_DIR=".";
my %hashs;
my %hosts;
for(< $ACL_DIR/*.acl >) {
my $file = $_;
chomp $file;
next if (($file =~ /^.*\/\.\.$/)||($file =~ /^.*\/\.$/));
if(open(FILE,"<$file")) {
while(<FILE>) {
my $line=$_;
chomp $line;
next if((length($line)<2) || ($line =~ /^#/));
if($line =~ /\^([hH][tT][tT][pP][sS]?:\/\/)([^\/]+)([^\#]+)/) {
$proto=$1;
$host=$2;
$url=$3;
my $reg1=qr/^$host$/;
my $reg2=qr/^$url/;
if(defined $hosts{$host}) {
} else {
$hosts{$host}=$reg1;
}
}
}
close(FILE);
}
}
$|=1;
while (<>) {
@X = split;
$url = $X[0];
if ($url =~ /^http:\/\/([^\/]+)/) {
my $host=$1;
if(defined $hosts{$host}) {
$url =~ s/^http:/https:/;
} else {
while((my ($k,$v)=each(%hosts))) {
if($host =~ /$v/) {
$url =~ s/^http:/https:/;
last;
}
}
}
print "$url\n";
} else {
print "$url\n";
}
}