...in initialisation section... our $zip; tie $zip .... # magic here sub ZIP::TIE::FETCH { # smoke and mirrors here $zip = $zip_server->get_zip_codes(); untie $zip; # and leave the data in $zip } ..and where we use it... print "selectbox-header"; for (@$zip) { print "selectbox line"; } print "selectbox-end";