in reply to Changing value passed to sub

The elements of @_ passed to the sub are aliases to the outside values. Shifting them in to an assignment kills off the alias property. You can write,

sub my_sub{ if (handle_not_valid($_[0])){ $_[0] = new_handle(); } # ... }
That will change the value outside the sub if that value is modifiable. If the sub is called with an unmodifiable value, an error will result. You will probably want to handle that error.

After Compline,
Zaxo