1
例如,
$string = "Hello"
$string =+ " there"
在Perl中,你可以做
my $string = "hello"
$string .= " there"
这似乎有点冗长,必须做
$string = $string + " there"
或
$string = "$string there"
例如,
$string = "Hello"
$string =+ " there"
在Perl中,你可以做
my $string = "hello"
$string .= " there"
这似乎有点冗长,必须做
$string = $string + " there"
或
$string = "$string there"
您实际上已经向后操作员。它应该是+=
,不=+
:
$string = "Hello"
$string += " there"
下面是一个演示:
PS > $string = "Hello"
PS > $string
Hello
PS > $string += " there"
PS > $string
Hello there
PS >
然而,这是你可以得到你想要的东西最快/最短的解决方案。
有多尴尬,我甚至没有尝试过! –