No; guess again.
The problem is with @dirs. Did you assign it in the BEGIN block? If you declare it with "my", make sure you do that in outside the BEGIN block. the actual use line should also be outside (after) that block.
And is $0 actually the full path? I think perhaps your @dirs array is just too short for the splice. You might have to use rel2abs to make it so.
Anyway, I would do it another way, and put the code in a do block. Untested:
use File::Spec::Functions qw(rel2abs)
use lib do {
my @dirs = split('/', rel2abs($0));
splice(@dirs,-2);
my $install_dir = join('/',@dirs);
$install_dir."/lib" };