Get rid of the "used only once" by putting an our $portalserver; in your code (doesn't have to be in any particular scope; just has to happen before the main script is done compiling). Use use vars wq/$portalserver/; instead if on perl older than 5.6.0 or if the variable has a different package name (e.g. use use vars qw/$foo::bar/;).