well one possibility is that "write" writes to the currently selected filehandle. Try "write STDOUT;"

But since you say that you are getting at least some kind of line, the leading spaces in the 2nd format statement may also be an issue - this is a finicky critter - one reason why I don't recommend it. The first answer on Monks is not always the "best answer" - and I would include myself in that general statement also!.

In the future, I think you will wind up being much happier with printf().

Anyway, the difference that I see is this: (2nd format does not start in column 1).

format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<< +<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<< @row . not the same as: format STDOUT = @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<<<<<<<<< @<<<<< +<<<<<<< @rows .
Update: After looking at the doc's, the "." - to end the format - has to be in column 1. It doesn't say that the format itself must start in column 1, but at the moment I am at a loss for any other ideas. The two statements appear to be so similar that that's the only thing I can think of at the moment.

I did look at what it will do if "the data doesn't fit" and you get #'s in that field. This is almost always not what is desired. I wrote a recent post at printf exact field width of floating point number that talks about using sprintf() to decide how wide a field will actually be printed and how to use a different format spec in printf() if it "doesn't fit" within a fixed number of characters (in this case using %g instead of %f). This is extremely rare. (update: I liked BrowserUK's answer in that thread also, if you give %g "enough room to work", it will do a "good job").

All of which will be better than the "format" idea for numeric values. For strings, this whole idea of how to display the decimal number is mute. For strings, the issue is whether you are going to truncate the string or allow the columns for that line to "go astray" if the value doesn't "fit".

In general printing "something" is better than printing "nothing or just #'s". But almost always, print the data to the precision needed and if some weird line doesn't line up, then so be it. Always add an explicit space between format specifications to ensure at least one blank space between values.

In summary, this "format" idea was a good one, but it doesn't work out well in practice.


In reply to Re^3: Assistance fixing a "format" call by Marshall
in thread Assistance fixing a "format" call by bobdabuilda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.