sub set { my( $pos, $newval )= @_; $_[$pos]= $newval; return $_[$pos]; } print set( 2, "hello", undef ), $/; # prints "hello" my $x= "one"; print set( 2, "two", $x ), $/; # prints "two", changes $x print $x, $/; # prints "two" print set( 2, "four", $x.3 ), $/; # prints "for", $x unchanged print $x, $/; # prints "two" print set( 2, "hello", "goodbye" ); # dies with: # Modification of a read-only value attempted