Re: help with perl
Hi,
The pattern you have is:
//.*riddler.com/Commonwealth/bin/statdeploy.* //www.taz.net.au/blank_ad.gif
However, on adding printing to your script, I discovered the
key came out to be:
DEBUG key = //.*riddler.com/commonwealth/bin/statdeploy.*
See? the capitalization is lost.
I think in sendmail, all input is supposed to be case
insensitive. The manual page for makemap says:
-f Normally all upper case letters in the key are folded to low
er case. This flag disables that behaviour. This is intend
ed to mesh with the -f flag in the K line in sendmail.cf.
The value is never case folded.
I am enclosing the current version of your script that I have
hacked; please note the advanced software engineering techniques for
debugging, namely, use printf statements ;-)
Hope this helps.
manoj
#!/usr/bin/perl
$debug=1 ;
use DB_File;
use Fcntl;
$|=1;
$redir_file = 'redir.db' ;
tie (%redir_db, 'DB_File', $redir_file, O_RDONLY, 0644, $DB_HASH) || die ("Cannot open $redir_file");
while (<>) {
chop ;
# Squid gives us: URL ip-address/fqdn ident method
($url, $address, $ident, $method) = /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/ ;
print STDERR "DEBUG address=$address,ident=$ident,method=$method\n\turl=$url\n";
$out="" ;
$found = 0 ;
while ((($key,$record) = each %redir_db) && ! $found) {
print STDERR "DEBUG \tkey = $key\n";
if ($url =~ m!$key!) {
$out = $url ;
$out =~ s!$key!$record! ;
$found = 1 ;
print STDERR "DEBUG out = $out, recrd = $record\n";
} ;
} ;
if ($debug) {
print $url, "==>" ;
} ;
print $out, "\n\n" ;
}
untie %redir_db
--
"Nat Goldstein and Jim Simmons in Florida, Curtis Beseda out west who
has destroyed abortion clinics, these men are looked up to by my arm
of the movement as the foremost heroes of the movement ...." James
J. Condit, Jr., Cincinnatus Party's perennial candidate for city
council, "Mike Cuthbert Show," WCKY_AM, 1/22/87, as quoted in "The
Far Right, Speaking For Themselves," a Planned Parenthood pamphlet
Manoj Srivastava <url:mailto:srivasta@acm.org>
Mobile, Alabama USA <url:http://www.datasync.com/%7Esrivasta/>
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: