Subject: | Home discovery is dangerously naive... |
The way you try to discover the default rc file is quite naive and a potential error source.
#Check usual env vars
for my $var ( qw(HOME USERPROFILE HOMESHARE) ){
my $path = catfile( $ENV{$var}, $rc_file );
return $path if -f $path;
}
What you need to do here is
1) Check for the installation of File::HomeDir. If it exists, use it first.
2) For each ENV key you check, you need to make sure the key actually exists.
So
# Use File::HomeDir here if installed...
#Check usual env vars
for my $var ( qw(HOME USERPROFILE HOMESHARE) ){
next unless defined $ENV{$var};
my $path = catfile( $ENV{$var}, $rc_file );
return $path if -f $path;
}
BTW, using File::HomeDir like that is going to go a long way to make Perl::Critic Win32-safe.