|
|
1
10
匹配运算符默认为使用
从
I/O Operators
...
Ordinarily you must assign the returned value to a variable, but there
is one situation where an automatic assignment happens. If and only if
the input symbol is the only thing inside the conditional of a "while"
statement (even if disguised as a "for(;;)" loop), the value is autoâ
matically assigned to the global variable $_, destroying whatever was
there previously. (This may seem like an odd thing to you, but youâll
use the construct in almost every Perl script you write.) The $_ variâ
able is not implicitly localized. Youâll have to put a "local $_;"
before the loop if you want that to happen.
The following lines are equivalent:
while (defined($_ = )) { print; }
while ($_ = ) { print; }
while () { print; }
for (;;) { print; }
print while defined($_ = );
print while ($_ = );
print while ;
This also behaves similarly, but avoids $_ :
while (my $line = ) { print $line }
|
|
|
2
4
您可以使用以下方法修复此问题:
要避免警告:
|
|
|
BlurKid · R中for循环时结果的奇怪差异 1 年前 |
|
|
bigjdawg43 · 迭代多个数据帧中的列并有条件地执行操作 1 年前 |
|
|
xhamsterIT · 循环VBA Microsoft Excel 1 年前 |
|
|
Nico44044 · 使用for循环遍历Django模型字段 1 年前 |
|
|
chanbo chung · 如何在聚合中获得所有可能的组合 1 年前 |
|
|
Himanshu · 无法在逐行二进制搜索中迭代2D数组中的所有行 2 年前 |
|
|
stephr · 循环为多个变量选择最接近另一个日期的日期 2 年前 |