Last updated on February 16th, 2022 at 07:31 am

This tutorial is a very simple perl script to prompt User Input And loop it according to the number of times we provide as the input.

The script also has Sleep Functionality added for your reference. Save the code below in a file named userinput.pl

#!/usr/bin/perl
print "My First Perl Program \n";
print "#########################################";
print "\nWhat is your name\n";
$a=<>;
print "Hello $a\n";
print "Enter the number of times you need to loop your name\n";
$b=<>;
for ($count=1; $count<=$b; $count++) {  print "This is $a $count\n"; $num = 5; while($num--){         sleep(1);         } }

Here is the output of above script

$ ./userinput.pl
My First Perl Program
#########################################
What is your name
mistonline.in
Hello mistonline.in

Enter the number of times you need to loop your name
2
This is mistonline.in
 1
This is mistonline.in
 2

Leave a Reply

Your email address will not be published. Required fields are marked *