sub web_size{ my $url = shift || die "Need URL to check"; REDIR: { $url =~ /^(http:\/\/)(.*?)(\/.*)$/; my $protocol = $1; my $domain = $2; my $path = $3; $domain = $domain.":80" unless ($domain =~ /80/); my $handle = IO::Socket::INET->new($domain) || die "can't connect to $domain: $!"; $handle->autoflush(1); print $handle <){ chomp; $_ = lc; #print $_."\n"; $http = $_ unless ($http); my ($option,$result) = split(/: /); $data{$option} = $result; } if ($http =~ /301|302/){ #print "Redir: ".$data{'location'}."\n"; $url = $data{'location'}; redo REDIR; }else{ return $data{'content-length'}."\n"; } } }