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
In reply to Print format not working by catfish1116
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |