perllist-separator

Why can't I set $LIST_SEPARATOR in Perl?


I want to set the LIST_SEPARATOR in perl, but all I get is this warning:

Name "main::LIST_SEPARATOR" used only once: possible typo at ldapflip.pl line 7.

Here is my program:

#!/usr/bin/perl -w

@vals;
push @vals, "a";
push @vals, "b";

$LIST_SEPARATOR='|';

print "@vals\n";

I am sure I am missing something obvious, but I don't see it.

Thanks


Solution

  • perlvar is your friend:

    $LIST_SEPARATOR
    $"

    This is like $, except that it applies to array and slice values interpolated into a double-quoted string (or similar interpreted string). Default is a space. (Mnemonic: obvious, I think.)

    $LIST_SEPARATOR is only avaliable if you use English; If you don't want to use English; in all your programs, use $" instead. Same variable, just with a more terse name.