sub get_connection { # ... my $sess_id = "Session ID Goes Here"; return MySession::new($sess_id); } # $sess_id out of scope now my $x = get_connection(); my ($p, $q, $str) = MySession::get($x); # internally references PV part of $sess_id