use Cwd qw( realpath ); use File::Basename qw( dirname ); my $script_dir; BEGIN { $script_dir = dirname(realpath($0)); } use lib $script_dir;