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

Re: [MacPerl] Variable Names in Formatted Output

At 1:08 PM -0400 6/11/99, Ronald J Kimball wrote:
>I am very skeptical about the 'problems' in this case.


Maybe there is a misunderstanding about what the script is supposed 
to do.  When the script asks for a 'list' of words, it means enter 
one word on a line, and end with Control-D (on the mac/unix) or... 
what is it, Control-Z on a PC?


Then it prints out those words, right justified, using a field as 
wide as you selected (where possible--the entry for $columnz has to 
be greater than the shortest of the words before you'll see any 
formatting.)  Use a big number, as Ronald demonstrated in his msg.

Remember that <STDIN> grabs a line at a time.  So if you type in a 
'list' of words:

eeney meeney miney mo

Then you get that one string, right justified, (if possible,) or 
stuck up against the left edge of your window and stretching across 
the screen--if the string length is greater than the number you 
entered for $columnz.

If Robert wants the script to work with long strings, then he'll need 
to do a little bit of work with split().

As for the message name: yes, there is a variable name in the format 
statement, and yes, this is the right way to put a variable name in 
the middle of a format statement to insure it is parsed they way you 

For an explanation of what's going on in the printf statement, read 
about sprintf in "Programming Perl," pp. 222-3.  If you have it/when 
you get it.  For this use of {}, see 255.


P.S. Here is the relevant line from p. 223

   printf "%${width}.${precision}f\n", $value;

That prints $value in a field $width spaces wide with $precision 
digits after the decimal point (or the precision for exponential 

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org