Why can't I set $ LIST_SEPARATOR in Perl?

I want to set LIST_SEPARATOR to perl, but all I get is a 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’m sure that I’m missing something, but I don’t see it.

thanks

+3
source share
4 answers

perlvar is your friend:

$LIST_SEPARATOR
$"

This is similar $,, except that it applies to array and slice values ​​interpolated into a double-quoted string (or a similar interpreted string). The default value is a space. (Mnemonic: obviously, I think.)

$LIST_SEPARATOR , use English; use English; , $". , .

+9

$" = '|';

use English;

.

perlvar. , .

Perl. . , ,

use English;

. . , awk. ,

use English '-no_match_vars';

$PREMATCH, $MATCH $POSTMATCH, . . English.

+12

( ), English.

:

  • (.. )

:

- , Perl . , , , :

{
  local $" = '|'; # Set interpolated list separator to '|'
  # fun stuff here...
}
+7

:

use strict;

( -w):

use diagnostics;
+2

Source: https://habr.com/ru/post/1705811/


All Articles