Help for this page

Select Code to Download


  1. or download this
    my @userArray = qw(batman robin joker);
    my @userArray2; #this is a null array
    
    my @mainArray = (@userArray, @userArray2);
    print("Number of elements: ", scalar(@mainArray), "\n");   # 3
    
  2. or download this
    my @mainArray = ('batman', 'robin', undef, 'joker');
    print("Number of elements: ", scalar(@mainArray), "\n");   # 4
    @mainArray = grep { defined } @mainArray;
    print("Number of elements: ", scalar(@mainArray), "\n");   # 3