Fix declaration of debug vars so -d switch works correctly

Changed the declaration of variables $DEBUG and $opt_d from "my" to
"our" - the debug setting wasn't working because $opt_d is set within
the "getopts" routine, so we need it to be global.