Help for this page

Select Code to Download


  1. or download this
    my @arr1 = ("foo", "", "bar", "", "baz");
    my @arr2 = grep $_, @arr1;
    ...
        $" = ', ';
        print "@arr1\n@arr2\n";
    }
    
  2. or download this
    my @arr1 = ("foo", "", "bar", "", "baz");
    my @arr2;
    foreach (@arr1) {
        push @arr2, $_ if $_ ne '';
    }