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"); }
In reply to Re^2: Return Value in Subroutine
by citromatik
in thread Return Value in Subroutine
by rose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |