Help for this page

Select Code to Download


  1. or download this
    join ', ', @a
    
  2. or download this
    my $string = join ', ', @a[$[..$#a-1];
    $string .= ", and $a[-1]";
    
    # or in one line
    my $str = join ', ', @a[$[..$#a-1], "and $a[-1]";
    
  3. or download this
    my $str = @a > 1 ? join ', ', @a[$[..$#a-1], "and $a[-1]" : $a[0];