[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Variable Names in Formatted Output

Title: Re: [MacPerl] Variable Names in Formatted Output
At 14.23 -0400 1999.06.10, Robert wrote:
>I'm learning the examples from _Learning Perl on Win32 Systems_ using my
>PowerBook. The following example does not work correctly. It appears that I
>am incorrectly specifying that columnz is a variable. The script just
>outputs words, right-justified, in a column of an arbitrary width. What am I
>doing wrong?
>print "How many columns? ";
>chomp ($columnz = <STDIN>);
>print "Enter a list of words:\n";
>chomp (@list = <STDIN>);
>foreach (@list) {
> printf "%${columnz}s\n", $_;
> }

Chris wrote:
Looks fine, but your post has a problem.  You say "The following example
does not work correctly", without telling us what it is doing that is wrong.

The first five lines execute as expected. When I enter Cntrol-D to end the array entry, I fully expect the lines to print. They do not. Nothing happens. I feel confident in the loop. the printf syntax may have me confused. As the title of the post indicates. Is there something wrong with a variable used with curly quotes in this manner?

Robert Ligon