git://git.jankratochvil.net
/
redirector-ad.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1a0d193
)
Rewritten to Perl to cure the slowness
author
short
<>
Sun, 25 Nov 2001 22:00:59 +0000
(22:00 +0000)
committer
short
<>
Sun, 25 Nov 2001 22:00:59 +0000
(22:00 +0000)
redirector
patch
|
blob
|
history
diff --git
a/redirector
b/redirector
index
fd8920c
..
74d3b58
100755
(executable)
--- a/
redirector
+++ b/
redirector
@@
-1,9
+1,29
@@
-#! /
bin/sh
+#! /
usr/bin/perl
#
# $Id$
#
# $Id$
-DIR_AD=/usr/local/squid/etc/ad
+use strict;
+use warnings;
-exec /usr/bin/perl -e '$|=1; while (<>) {
-'"` (cd "$DIR_AD";m4 -P main)|awk '/./{print "s@^http://"$0".*$@http://localhost/cgi-bin/redirector-ad.cgi?"$0"@;"}' `"'
-print; }'
+use constant DIR_AD => "/usr/local/squid/etc/ad";
+
+
+chdir DIR_AD or die "chdir ".DIR_AD.": $!";
+
+my($patt)="";
+open(M4,"-|","m4 -P main") or die "m4 run: $!";
+while (<M4>) {
+ chomp;
+ next if !$_;
+ $patt.="|" if $patt;
+ $patt.=$_;
+ }
+close M4;
+
+select STDOUT;
+$|=1;
+
+while (<>) {
+ s@^http://($patt).*\n$@http://localhost/cgi-bin/redirector-ad.cgi?$1\n@os;
+ print;
+ }