use Socket; use IO::Socket::Socks; my $host = "teh-web-box"; my $port = "80"; my $phost = "teh-proxy-box"; my $pport = "1080"; my $fh = "fixed_string"; my $s; if ( no_proxy() ) { #part 1 ... } else { $s = new IO::Socket::Socks( ProxyAddr => $phost, ProxyPort => $pport, ConnectAddr => $host, ConnectPort => $port, ); } # now reconcile $fh and $s.