Help for this page

Select Code to Download


  1. or download this
    Named        Anonymous
    @array       []
    %hash        {}
    
  2. or download this
    @array;
    
  3. or download this
    [];
    
  4. or download this
    $arrayref = [];
    
  5. or download this
    $ary = $arrayref;
    push @$ary,"foo";
    print $arrayref->[0]; # prints "foo" \
    print @$arrayref[0];  # prints "foo" - same pointer value in $ary and 
    +$arrayref
    print $ary->[0];      # prints "foo" /
    
  6. or download this
    for("foo") {
        print;     # prints foo
        undef $_;  # dies with "Modification of a read-only value attempte
    +d"
                   # - literals cannot be modified
    }
    
  7. or download this
    my $ref = ["my","list"];
    
  8. or download this
    for (@$ref) {
        print;
        $_ = undef;
    }
    # the [] array pointed to with the content of $ref is now [undef,undef
    +]