" I bet $a is a relative uri or not a uri at all."
$a is a uri. I got this script from the CS department at UNC and I know it works. My only problem is that my hosting company didn't have URI installed to I had to install it locally in my domain.
My host uses Apache on Unix.
"perhaps you forgot to load "URI::_generic?"
I loaded the entire URI module including all 40+ supporting packages.