1#!/usr/bin/perl -w
2use HTTP::Proxy;
3use HTTP::Proxy::HeaderFilter::simple;
4
5# call this proxy as
6# eg/switch.pl proxy http://proxy1:port/,http://proxy2:port/
7my %args = @ARGV;
8my @proxy = split/,/, $args{proxy};
9my $proxy = HTTP::Proxy->new(@ARGV);
10
11$proxy->push_filter(
12    request => HTTP::Proxy::HeaderFilter::simple->new(
13        sub {
14            shift->proxy->agent->proxy( http => $proxy[ rand @proxy ] );
15        }
16    )
17);
18
19$proxy->start;
20