use strict; use warnings; MyPackage->import; #My main code $globalVar=1; myfunction(); #===================== BEGIN{ package MyPackage; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(globalVar myfunction); our $globalVar; sub myfunction {} #Rest of package code... }