-2

我制作了一个简单的 whois 脚本,可以返回域的 whois 信息。完成后,它会返回到原始终端,示例如下。

user@ubuntu:; perl script.pl
Enter domain name: name.com
etc... whois information displays here.
user@ubuntu:;

最后“user@ubuntu”返回,我如何让它回到开始?

我想循环它。

4

2 回答 2

1

在 perl 中,

而 ( 1 )
{
    print "输入域名:";
    我的 $domain = <>;
    最后除非 $domain && $domain =~ /\w/;
    域 =~ s/\s+//g; #super-chomp 是个好主意
    你的代码在这里...
}

除非 EOF 产生 undef ,否则使用两阶段,因为我不希望 undef =~ /\w/ 在激进警告级别上产生运行时警告。

于 2011-08-11T11:08:22.757 回答
0

在 bash 你可以这样做:

while [ /bin/true ]
do
    perl script.pl
    sleep 1
done
于 2011-08-11T10:18:16.717 回答