Sometimes I need a useful utility function, for example List::Util::max in the middle of a large program that does a lot of things. So if i do
use List::Util 'max';
At the top of my program, I am stuck with this symbol, polluting my entire namespace, although I only need it in one subroutine.
So, I was thinking of trying another template:
use List::Util ();
There are two problems with this. Firstly, it will not automatically unimport at the end of the block (drat.) I would have to undo everything using unimport .
Another problem is that the prototypes do not seem to apply correctly, so I have to say max( @foobar ) instead of a more beautiful version without letters.
Is there an easy way to temporarily import characters for a block that will automatically delete them at the end of the block and that will also handle prototypes correctly?
import perl lexical-scope
friedo
source share