Blob


1 #!/usr/bin/perl
3 #Modify the previous program to let the user choose the column width, so that
4 #entering 30, hello, good-bye (on separate lines) would put the strings at the
5 #30th column. (Hint: see "Interpolation of Scalar Variables into Strings" on
6 #page 32, about controlling variable interpolation.) For extra credit, make the
7 #ruler line longer when the selected width is larger.
9 use v5.10;
10 use warnings;
11 use strict;
12 use utf8;
14 chomp(my @lines = <>);
15 my $width = shift @lines;
16 if ($width > 70) {
17 print "1234567890"x($width/10 + 1) ."\n";
18 } else {
19 print "1234567890"x7 ."\n";
20 }
21 printf "%${width}s\n"x@lines, @lines;