I\'ve got this Perl script:
#!/usr/bin/perl
use strict;
use warnings;
print , \"\\n\";
print , \"\\n\";
print , \"\\n\";
If you want to loop printing your text an user defined number of times, you can use a do while loop like this:
#!/usr/bin/env perl
#Program: stdin.pl
use strict;
use warnings;
use feature 'say'; # like print but automatic ending newline.
my $i = 1; # Our incrementer.
my $input; # Our text from standard input that we want to loop.
my $total; # How many times we want to print the text on a loop.
say "Please provide the desired text of your standard input.";
chomp($input = ); # chomp removes a newline from the standard input.
say "Please provide the amount of times that you want to print your standard input to the screen.";
chomp($total = );
say ">>> I'm in your loop! <<<";
do # A do while loop iterates at least once and up to the total number of iterations provided by user.
{
say "Iteration $i of text: $input";
$i++;
}while($i <= $total);
say ">>> I'm out of your loop! <<<";
This is what I get when I execute the code with "Hello", and "8" from standard input:
> perl .\stdin.pl
Please provide the desired text of your standard input.
Hello!
Please provide the amount of times that you want to print your standard input to the screen.
8
>>> I'm in your loop! <<<
Iteration 1 of text: Hello!
Iteration 2 of text: Hello!
Iteration 3 of text: Hello!
Iteration 4 of text: Hello!
Iteration 5 of text: Hello!
Iteration 6 of text: Hello!
Iteration 7 of text: Hello!
Iteration 8 of text: Hello!
>>> I'm out of your loop! <<<