什么是 @.在Perl?

前端之家收集整理的这篇文章主要介绍了什么是 @.在Perl?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是什么 @. 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 @."

我记不起曾经遇到它,并没有在perlvar和perldata中看到它.

解决方法

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.

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

原文链接:https://www.f2er.com/Perl/171430.html

猜你在找的Perl相关文章