catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:
below is my code:
#!/bin/perl use v5.10; say "Please enter a few lines of text. Press crtl-D when finished"; @text_lines = <STDIN>; chomp($text_lines); say "Please enter the width of the column: "; $column = <STDIN>; $ruler = "1234567890"; say "$ruler" x $column; foreach (@text_lines) { #printf "%${column}s\n", $_; printf "%${column}s\n", $_; }
Here is my output:
Please enter a few lines of text. Press crtl-D when finished
rrrrr eeeeee tyyyyy
Please enter the width of the column: 10 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
%10
s
%10
s
%10
s
I copied the code straight out of Learning Perl (7th edition). I typed in 3 lines of text as well as the width I wanted. The output should have been the repeating numbers, (1-0), and then below the text lines with aligned columns, (width called in by <STDIN>. I guess it worked ok for the authors ... not so much for me though .... Any help would be appreciated.
Thanks, Catfish
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Print format not working
by toolic (Bishop) on Oct 04, 2018 at 17:26 UTC | |
by catfish1116 (Beadle) on Oct 04, 2018 at 18:37 UTC | |
Re: Print format not working (updated)
by AnomalousMonk (Archbishop) on Oct 04, 2018 at 17:35 UTC |