http://www.perlmonks.org?node_id=1141586


in reply to Is this a safe way to 'un'-require a module?

I would wait until you know that this is causing an issue, premature optimization is the root of all evil. ;) Having said that, here's my take on the solution (given i did understand the problem correctly)

use strict; use warnings; if (shift) { eval "use Data::Dumper"; } print Data::Dumper->Dump( [ 1 .. 10 ] );
The obvious problem with this solution is you lose features from Autoload --- this approach works best with object oriented packages that require instantiation but you can still work around non OO packages. Most of the time ... ... these kinds of concerns tend to open cans of worms. :/

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)