I can't see anything wrong with your printf statement, and it works for me:

open $FORM, '>', 'column.FORM' or die $!;; @c = (1.2, 1.3, 1.4, 1.5); $t = '%10s'x@c . "\n"; printf( $FORM $t, @c );; close $FORM;; ^C C:\test>type column.FORM 1.2 1.3 1.4 1.5

so what is going wrong I have no idea.

Equally your comment, #chomp; # this gives me syntax errors??? makes no sense, chomp; cannot be a syntax error.

Your comments in an earlier thread to the effect of "I don't know why it didn't work before but it does now", all suggest that the way you are writing your code; or running your scripts, or some other environmental factor is causing you to experience problems that are not down to Perl, or the code you are posting.

The upshot is, I'm going to suggest that you try to seek out someone local to you with some programming knowledge to watch you write and run a small, simple program and perhaps he will see the problem that we cannot see when interacting with you this way.

A final comment on your script above: You do know that:$columns[$#columns] is a single value?

If so, why are you using a foreach loop to iterate over a single value?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: divide multi-column input file into sub-files depending on specific column's value by BrowserUk
in thread divide multi-column input file into sub-files depending on specific column's value by angela2

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.