BEGIN { our $DEBUG = 1; } #### my $DEBUG = $main::DEBUG; However, $DEBUG was then not available within main!

I don't know the reason for that, but I resolved it by doing this further down in main: my $DEBUG = $main::DEBUG;