in reply to array element seperators

$" is the seperator for arrays when they're interpolated with double quotes or a qq(). $, is the seperator when they're printed without quotes.
print @array; # is the same as 'print join($,, @array);' print "@array"; # is the same as 'print join($", @array);'

Replies are listed 'Best First'.
Re: Re: array element seperators
by MrNobo1024 (Hermit) on Mar 11, 2001 at 01:13 UTC
    Also, with $, it dosen't have to be an array. $, is also printed between items in a print() statement:
    $, = "!"; print 1, 2, 3; # prints 1!2!3
      ...because $, applies to a list following a print statement, not just to an array in a print statement. But be careful. This can be handy but can also produce unexpected results:
      my @items = qw(a b c d e); $, = '||'; print @items, "\n"; # Prints: a||b||c||d||e||
      Which may not be what you wanted if you forgot that the "\n" became an additional item in the flattened list after the print.
        dvergin wrote:
        because $, applies to a list following a print statement, not just to an array in a print statement.

        But aren't all lists arrays, and all arrays (other than associative arrays) lists? I thought that the two terms, arrays and lists, were more or less synonymous except for the aforementioned associative arrays a.k.a. hashes.