为什么 perl 将刻度转换为冒号? [英] Why does perl translate a tick into a colon?
本文介绍了为什么 perl 将刻度转换为冒号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
鉴于此程序:
use strict;
use warnings;
my $zx_size = 32;
my $x = "$zx_size'h0";
Perl 告诉我:
Name "zx_size::h0" used only once: possible typo at concat.pl line 7.
Use of uninitialized value $zx_size::h0 in string at concat.pl line 7.
为什么?
似乎有多种方法可以指定 var 的命名空间.还有其他的吗?
It appears there are multiple ways to specify the namespace of a var. Are there others?
是否可以关闭此行为?
推荐答案
旧的包分隔符是一个单引号 '
,它最初用于方便 Ada 程序员过渡到 Perl.它被替换为 ::
以提高可读性并简化 C++ 程序员的转换.
The old package delimiter was a single quote '
which was originally used to ease transition to Perl for Ada programmers. It was replaced with ::
to be more readable and ease the transition of C++ programmers.
它仍然支持向后兼容,但您可以将标量包装在 {..}
中以使其正确插入.
It is still supported for backwards compatibility, but you can wrap your scalar in {..}
to have it interpolate correctly.
my $x = "${zx_size}'h0";
或
my $x = "$zx_size\'h0";
这篇关于为什么 perl 将刻度转换为冒号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文