# Debug perl script

**URL:** <https://community.unix.com/t/debug-perl-script/310933>\
**Category:** Shell Programming and Scripting\
**Created:** [May 28, 2012, 8:34am UTC](https://community.unix.com/t/debug-perl-script/310933 "2012-05-28T08:34:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamie\_123](https://community.unix.com/letter_avatar/jamie_123/32/6_22734026db12803ebb3e059622ac3534.png) [@jamie\_123](https://community.unix.com/u/jamie_123)\
**Post date:** [May 28, 2012, 8:34am UTC](https://community.unix.com/t/debug-perl-script/310933/1 "2012-05-28T08:34:43Z")

</div>

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.

```nohighlight
#!/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

```

```nohighlight
#!/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-

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

```

Thanks a lot.
