Help for this page

Select Code to Download


  1. or download this
    my @array = qw/one two three four five/;
    print scalar @array;
    __OUTPUT__
    5
    
  2. or download this
    my @array = qw/one two three four five/;
    print $#array;
    __OUTPUT__
    4
    
  3. or download this
    my @array = qw/one two three four five/;
    $array[2] = undef;  # undefine one of the elements.
    print scalar grep { defined $_ } @array;
    __OUTPUT__
    4
    
  4. or download this
    my @array = qw/one two three four five/;
    print $array[-1];
    __OUTPUT__
    five
    
  5. or download this
    my @array = qw/one two three four five/;
    $#array = 99;
    print scalar @array;
    __OUTPUT__
    100