use Data::Dumper; # much later in the program if ( $some_condition) { warn "DEBUG: ", Dumper ( $whatever ); } #### if ( $some_condition ) { require Data::Dumper; warn "DEBUG: ", Data::Dumper::Dumper( $whatever ); }