I’ve always wondered this. I have a habit of always adding
use strict;
use warnings;
use Data::Dumper;
to the top of every script I write. Does this add overhead if I don’t even use the Dumper function? Also, in most cases Data::Dumper was called earlier in another package but I need it in this package so I include it again. In this case does it produce additional overhead?
If they have
BEGINblocks orimportroutines, then yes, it always adds overhead. Also any mainline code will be executed eventually and anyINIT,CHECK, andENDblocks will also execute.The only way it won’t add overhead is if the module expects
useto be nothing more than likerequire. (Of course,requirealso runs everything except theimportroutine, but that’s why I mentioned the view from theuse-d module. It “expects” to be nothing but a simplerequire.)If you want to retain that line, for some reason, just comment it out. In development, it’s okay to have modules that you don’t use. In QA or production, that’s a mistake, IMO.