# option 2 my $var = mysub(); sub mysub { # do stuff $var = "whatever"; return $var; # return is optional here, but makes what's going on explicit. }