use strict; ... # Call the subroutine to get the info. my ($cookieid, $cookiename) = getCookieInfo(); ... # The subroutine itself. sub getCookieInfo { # Keep these localised... my ($cookieid, $cookiename); ... # ... and then return them. return ($cookieid, $cookiename); }