Help for this page

Select Code to Download


  1. or download this
    my @y= (undef)= (3,4);
    
  2. or download this
    sub set {
        my( $pos, $newval )= @_;
    ...
    print $x, $/;                       # prints "two"
    print set( 2, "hello", "goodbye" ); # dies with:
    # Modification of a read-only value attempted
    
  3. or download this
    ($a,undef,$b)= @x;    # [undef] is copied
    ($a,"hi",$b)= @x;     # "hi" is aliased and so this dies
    @x= ($a,undef,$b);    # [undef] is copied so $x[1] is modifiable
    @x= ($a,"hi",$b);     # "hi" is copied so $x[1] is modifiable