Hi,

I've tried everything I can think of, but I feel like a 6th grader trying to
solve a 7th grade math problem:

I'm trying to build a "pretty-fier" for any tab-delimited text file
(basically space-pad the columns so the decimals line up).  I search through
the columns finding the longest field with and highest precision level for
each column, then create a format string for the printf command.  The guts
of it looks like this:


**************************************
$formatstr = "";
$index = 0;
foreach (@lwid) {
  $formatstr .= "%$lwid[$index].$lprec[$index]f".'\t';
  $index++;
}
substr($formatstr,-2,2) = "";
$formatstr .= '\n';

open(FILE, ">$file$ext") || die("Couldn't create $file$ext: $!\n");
        
    foreach (@content) {
        @fields = split;
        if (@fields) { printf FILE $formatstr, @fields; }
        else { print FILE $_; }
    }

close(FILE);
**************************************


... but that "printf" spits out actual "\t" and "\n"s.  How can I get the
printf to interpret those into tabs and newlines?

TIA.

- Bryan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to