in reply to Why am I getting a Divide by Zero error?

The problem line is this one:

$address =~ s!.*/\.\./(.*)!$base_url/$1!eg;

The /e option askes Perl to execute the replacement string before using it. Perl is therefore trying to divide $base_url by $1. Presumably, when you evaluate $1 as a number it becomes zero and causes your error.

You don't need the /e and can safely remove it.