Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Why does Perl have both $" and $, ? They both are the seperator between array elements when you print them, isn't that redundant?

Replies are listed 'Best First'.
Re: array element seperators
by MrNobo1024 (Hermit) on Mar 11, 2001 at 01:08 UTC
    $" 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);'
      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.
(tye)Re: array element seperators
by tye (Sage) on Mar 11, 2001 at 02:23 UTC

    What they said. Also $" ne $, by default (the former being " ", the latter "").

            - tye (but my friends call me "Tye")