BEGIN { eval "sub DEBUG() {" . ( $ENV{DEBUG} ? "1" : "0" ) . "}"; } # ... if( DEBUG ) { code here; } warn "Stuff" if DEBUG;