Greetings, halls of Monkdom.. I have been working on something I've always hated, the old school flat file. Its been easy to read the source data I have, because it is, after all is said and done, just tab separated info. After some rearranging and assembly of the info, it must be written out to another format of flat file. This second file is only data and space padded. I have looked at many modules, and have tried a few things, but what I am seeking is (hopefully) a perl module or method that will let me specify the array components in terms of the actual row and column they need to land on. In other words, I can pass $field[0] etc to this function or method and include that it starts on column 5, and is 10 wide, and padded with spaces. I have been messing with this kind of thing:

sprintf("%s%2s%17s\n", $fields[0], $fields[1], $fields[2]);

But it tends to float data around if the variable is not always the same output (length etc.) So I am hoping something that options a lot like the substring command exists somewhere I've missed, so I can basically tell the routine to place a variable at x column for y length with z filling -and also justify it. And it will always start there. Don't die laughing, but this project was tossed on me at the last minute and now I'm finally finishing it up in Perl. I actually used (cough cough) an old copy of Paradox4 in Dosbox -because the report designer lets me place things in specific lengths at specific locations!

I have looked at and read and tried all the postings I could find here on flat files, which mostly have to do with reading them, and then just writing them out as an array of separated text. I need specific formatted output, and know I am missing it somewhere!

Thanks in advance to anyone who can help...

I bow to your wisdom, and need more coffee.


In reply to Writing Fixed Flat Files by coffeeslob

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.