-2

I have made a 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.

RobEarl
  • 7,862
  • 6
  • 35
  • 50
Helloz
  • 1
  • 1

2 Answers2

1

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.

Gilbert
  • 3,740
  • 17
  • 19
0

in bash you can do:

while [ /bin/true ]
do
    perl script.pl
    sleep 1
done
Patrick B.
  • 11,773
  • 8
  • 58
  • 101