相关疑难解决方法(0)

42
推荐指数
4
解决办法
2537
查看次数

Perl中的数组问题

我是Perl的新手,在Perl中使用数组有些困难.有人可以向我解释为什么我无法在下面的脚本中打印数组的值.

$sum=();
$min = 999;
$LogEntry = '';
foreach $item (1, 2, 3, 4, 5)
{
  $min = $item if $min > $item;
  if ($LogEntry eq '') {
    push(@sum,"1"); }
    print "debugging the IF condition\n";
}
print "Array is: $sum\n";
print "Min = $min\n";
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

debugging the IF condition
debugging the IF condition
debugging the IF condition
debugging the IF condition
debugging the IF condition
Array is:
Min = 1
Run Code Online (Sandbox Code Playgroud)

我不应该Array is: 1 1 1 1 1(5次).有人可以帮忙吗?谢谢.

arrays perl

2
推荐指数
3
解决办法
243
查看次数

标签 统计

perl ×2

arrays ×1

sigils ×1

types ×1