下面的循环没有在标量之后停止,$quit显然不等于'j‘。为什么停不下来?
#!/usr/bin/perl -w
use strict;
my $quit = 'j';
while ($quit eq 'j') {
print "Enter whatever value you want and I bet I still continue.\n";
chomp (my $quit = <STDIN>);
print "quit equals: $quit\n";
} 发布于 2017-11-21 14:07:07
因为您在while循环中定义了一个新变量$quit。这就是你想要的:
chomp ($quit = <STDIN>);所以,没有我的。
https://stackoverflow.com/questions/47414952
复制相似问题