Debug perl script

Hi,

I am trying to get squid up and running using a redirector process, and every time I try to load a web page, squid fails miserably.

Can some one with perl and squid knowledge take a look at these codes and tell if something is wrong here.

#!/usr/bin/perl
#

$| = 1;

@endings = qw/ \.gif$ \.jpg$ \.jpeg$ \.png$ \.gz$ \.img$ \.tgz$ \.sit$ \.hqx$ \.image$ \.bin$ \.Z$ \.TAZ$ \.exe$ \.zip$ \.avi$ \.mov$ \.mp3$ \.mpg$ \.mpeg$ \.mov$ \.pkg$ \.wav$ \.dmg$ \.aiff$ \.pdf$ \.iso$ \.toast$ \.bz2$ \.js$ \.css$ /;
while (<>)
{
    ($url, $addr, $fqdn, $ident, $method) = m:(\S*) (\S*)/(\S*) (\S*) (\S*):;
        if ($method eq "GET")
        {
                $stop = 0;
                foreach $ending (@endings)
                {
                        if (($url =~ /$ending/i))
                        {
                                $stop = 1;
                                break;
                        }
                }
                if ($stop == 0)
                {
                        system("/opt/servers/squid_main/preget $url");
                }
        }
        print "\n";
}
# EOF
#!/bin/sh
#
# note: change 10.163.3.1:3129 to the IP and port of squid_back!
# also /tmp/targ must exist so wget stuff can be dropped there.
#
http_proxy="http://10.163.3.1:3129/"
export http_proxy
#echo "pregetting $1" >> /opt/data/squid_main/logs/myurls
wget -q --level=1 -nd  --directory-prefix=/tmp/targ/ -p "$1"
rm -rf /tmp/targ/* &
# EOF

I am trying to run the setup from here-

http://veloso.org/SquidConfig/SquidConfig.html

Thanks a lot.