gpt4 book ai didi

perl - 什么是 @。在 Perl 中?

转载 作者:行者123 更新时间:2023-12-02 04:38:26 26 4
gpt4 key购买 nike

perl 中的@. 变量是什么?

它似乎是一个特殊的、可写的全局变量,并且(令人惊讶地)不会插入双引号字符串中:

use strict;
use warnings;

# Under 5.8, 5.10, 5.12, 5.14, and 5.16,
# the following lines produce:

@. = (3, 2, 1); # no error
print "@.\n"; # "@."
print @., "\n"; # "321"

eval 'my @.; 1' # Can't use global @. in "my" at (eval 1)
or die $@; # line 1, near "my @."

我不记得以前遇到过它,并且在 perlvarperldata 中都没有看到它。

最佳答案

perldoc perlvar状态:

Perl variable names may also be a sequence of digits or a single punctuation or control character. These names are all reserved for special uses by Perl;

Perl identifiers that begin with digits, control characters, or punctuation characters are exempt from the effects of the package declaration and are always forced to be in package main; they are also exempt from strict 'vars' errors.

您正在使用保留名称。您不应期望能够依赖任何功能。

关于perl - 什么是 @。在 Perl 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11162279/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com