How to loop/restart a perl script?
I have made 开发者_如何学Pythona simple whois script that returns back the whois information of a domain. Once it's done it returns back to the original terminal, example below.
user@ubuntu:; perl script.pl
Enter domain name: name.com
etc... whois information displays here.
user@ubuntu:;
At the end the "user@ubuntu" returns, how do I get it to go back to the start?
I want to loop it.
In perl,
while ( 1 ) { print "Enter domain name: "; my $domain = <>; last unless $domain && $domain =~ /\w/; domain =~ s/\s+//g; #super-chomp is good idea your code here... }
Used a two-stage unless in case EOF produces undef as I don't want undef =~ /\w/ to produce run-time warnings on aggressive warning levels.
in bash you can do:
while [ /bin/true ]
do
perl script.pl
sleep 1
done
精彩评论