Also, to prevent duplication, note that both the path in "use lib" and the module version in "use Foo" can contain variables, but you need to populate them in the compile time.
my $required_version;
BEGIN {
$required_version = '1.2';
}
use lib "My/$required_version";
use Foo $required_version;