in reply to Re: Return Value in Subroutine
in thread Return Value in Subroutine
Or maybe pass a reference in the first place (making more obvious that you expect $var to be changed):
sub test { my ($val) = @_; $$val = "new_value"; } { my $var = "old value"; print("$var\n"); test(\$var); print("$var\n"); }
|
|---|