local::lib has special support for ~ paths. If you want to use the same paths with lib, you'll want to use $ENV{HOME}.
Also, while the "base" directory used by
local::lib is
~/perl5, that isn't the include path for libraries. It includes other directories like
bin and
man. The actual library path is in the
lib/perl5 subdirectory. These paths are not entirely determined by
local::lib itself, but also based on options given to
ExtUtils::MakeMaker and
Module::Build.
use lib $ENV{HOME}.'/perl5/lib/perl5';