Blame


1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
2 ffd9a51f 2023-08-04 jrmu
3 ffd9a51f 2023-08-04 jrmu # Write a program that prompts for and reads a string and a number (on separate
4 ffd9a51f 2023-08-04 jrmu # lines of input) and prints out the string the number of times indicated by
5 ffd9a51f 2023-08-04 jrmu # the number of separate lines. (Hint: use the x operator.) If the user enters
6 ffd9a51f 2023-08-04 jrmu # "fred" and "3", the output should be three lines, each saying "fred". If the
7 ffd9a51f 2023-08-04 jrmu # user enters "fred" and "299792", there may be a lot of output.
8 ffd9a51f 2023-08-04 jrmu
9 ffd9a51f 2023-08-04 jrmu use warnings;
10 ffd9a51f 2023-08-04 jrmu use strict;
11 ffd9a51f 2023-08-04 jrmu use utf8;
12 ffd9a51f 2023-08-04 jrmu
13 ffd9a51f 2023-08-04 jrmu print "string = ";
14 ffd9a51f 2023-08-04 jrmu my $str = <STDIN>;
15 ffd9a51f 2023-08-04 jrmu print "repeat = ";
16 ffd9a51f 2023-08-04 jrmu chomp(my $r = <STDIN>);
17 ffd9a51f 2023-08-04 jrmu
18 ffd9a51f 2023-08-04 jrmu print $str x $r;