Skip to content

Instantly share code, notes, and snippets.

Created Sep 19, 2015
What would you like to do?
use strict;
use warnings;
my %url;
# read config file
open CONF, $ARGV[0] or die "Error opening $ARGV[0]: $!";
while (<CONF>) {
next if /^\s*#?$/;
my @l = split("\t");
$url{qr/$l[0]/} = $l[$#l];
close CONF;
# read urls from squid and do the replacement
URL: while (<STDIN>) {
last if /^(exit|quit|x|q)$/;
foreach my $re (keys %url) {
if (my @match = /$re/) {
$_ = $url{$re};
for (my $i=1; $i<=scalar(@match); $i++) {
print "OK store-id=$_\n";
next URL;
print "ERR\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment