use File::Basename qw( dirname ); BEGIN { # Set working directory to the one in which the script resides. chdir(dirname($0)); }