Hi,

I'm trying to write a perl redirector for squid
which basically just takes a URL from STDIN and
returns another URL on STDOUT.

You have to use the autoflush feature so it
doesn't buffer requests (see below)..

I can't work out how to update file handles - I
want to log all requests to a log file, but if I
use open(FILE,">>logfile") it doesn't actually write
to the files until the handle is closed. How do I
get it updating on the fly as it does without $_?


#!/usr/local/bin/perl
$|=1;
while (<>) {
@X = split;
$url = $X[0];
if ($url =~ /^http:\/\/internal\.foo\.com/) {
$url =~ s/^http/https/;
$url =~ s/internal/secure/;
print "302:$url\n";
} else {
print "$url\n";
}
}

Thanks,
Andrew.

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to