coffeeslob has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing Fixed Flat Files
by runrig (Abbot) on Sep 16, 2015 at 18:43 UTC | |
|
Re: Writing Fixed Flat Files
by Tux (Canon) on Sep 16, 2015 at 18:53 UTC | |
|
Re: Writing Fixed Flat Files
by fishmonger (Chaplain) on Sep 16, 2015 at 18:26 UTC | |
by coffeeslob (Initiate) on Sep 16, 2015 at 19:43 UTC | |
by fishmonger (Chaplain) on Sep 16, 2015 at 20:25 UTC | |
|
Re: Writing Fixed Flat Files
by Anonymous Monk on Sep 16, 2015 at 21:55 UTC |