Help for this page

Select Code to Download


  1. or download this
    @list = (\$a, \@b, \%c);
    @list = \($a, @b, %c);      # same thing!
    
  2. or download this
    $list = [ @array[2,0] ];
    
  3. or download this
    $\ = "\n";
    my @array = ("my","list","here");
    ...
    print;           # prints "here" - last element of slice
    $_ = ("my","list","here");
    print;           # also prints "here"
    
  4. or download this
    #!perl/bin/perl
    
    ...
    
    $ref[0][0] = "changed";
    print "$ref[0][0] @array";
    
  5. or download this
    my @array = ("my","list","here");
    my @ref = ([\@array[2,0]],[\@array[1]]);
    ...
    print "${$ref[0][0]} @array";
    __END__
    changed my list changed
    
  6. or download this
    my @ref = (\@array[2,0],\@array[1]);
    my @ref = \(@array[2,0],@array[1]);
    my @ref = (\$array[2],\$array[0],\$array[1]);
    my @ref = \($array[2],$array[0],$array[1]);
    my @ref = \(@array[2,0,1]);