每次调用push()后添加索引
我在数组上使用 Perl push
,但每次我在数组上推送某些内容时,它也会推送该项目的索引。
我同时对 2 个数组执行相同的操作,其中一个按预期推送,但另一个则没有。
是什么导致了这种无法解释的行为?
if ($var->{color} == 1) {
push @x, $var->{variable}.'-l';
push @y, $var->{variable}.'-p';
}
else {
push @x, '__',
push @y, '__',
}
y
具有预期的数据,但 x
没有。
I'm using the Perl push
on an array, but every time I push something on the array, it also pushes the item's index as well.
I am doing the same action on 2 arrays at the same time, and one pushes as expected, but the other does not.
What could be causing this unexplained behavior?
if ($var->{color} == 1) {
push @x, $var->{variable}.'-l';
push @y, $var->{variable}.'-p';
}
else {
push @x, '__',
push @y, '__',
}
y
has the data as expected, but x
does not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要的是分号,而不是逗号:
You want semicolons, not commas here: