All pastes #2422099 Raw Edit

Untitled

public unlisted text v1 · immutable
#2422099 ·published 2017-03-22 06:01 UTC
rendered paste body
#!/usr/bin/perluse strict;use warnings;$|=1;my %url;# read config fileopen CONF, $ARGV[0] or die "Error opening $ARGV[0]: $!";while (<CONF>) {	chomp;	next if /^\s*#?$/;	my @l = split("\t");	$url{qr/$l[0]/} = $l[$#l];}close CONF;# read urls from squid and do the replacementURL: while (<STDIN>) {	chomp;	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++) {				s/\$$i/$match[$i-1]/g;			}			print "OK store-id=$_\n";			next URL;		}	}	print "ERR\n";}