I always feel a bit depressed when I go on a long geek/coding trip and don't come back having released something.
Since my work is slowly drifting more towards architecture and strategy where I do less coding than I used to, writing something this trip has been tough.
Fortunately, with a few hours to kill at Seattle airport I've managed to knock out File::HomeDir::Test, which is a way to test applications that use File::HomeDir safely and without spewing files into places that the installed application will discover later.
The pattern in your application is just the following...
use File::HomeDir::Test; use File::HomeDir;
Hi, this API is lacking. You're modifying state and expecting it to get used elsewhere and maybe it or maybe it won't or maybe something else now will fall over because things are possibly "strange."
Further, there's little reason for a user to think that loading something that looks like a class isn't going to be the normal sort of idempotent action we normally expect "Yes please, this I require that class X be loaded".
Quite sure this use of use() ought to look unlike a regular class-loading use of use(). Or the class loading could load HomeDir but replace it's environmental db with something custom?
Perhaps something like:
sub import {
$File::HomeDir::ENV = {
%main::ENV,
HOME =>...
};
}