in reply to Feedback request for text file manipulator
These assignments:
should really have the right side in parentheses, IMO. It just makes me cringe to have mismatched assignments.@text = "g total";
Do you really want a global replacement? It would be clearer to do this as one extraction:$ntext = (split (/;/)) [0]; $ntext =~ s/n01//g;
You've got useless (though not harmful) quoting here:($ntext) = /^n01([^;]+)/; # or /^n01(.+?);/;
and it could be written as just:print OUT "$_";
And since it's part of every branch of your if, you might as well just move it outside the whole conditional and get rid of the else clause.print OUT;
About your plans for future development. Instead of reading all the lines into an array, I would recommend you stop keeping track of @gcard and @pcard, since they never really change. They're entirely dependent on corresponding elements in @text. So just accumulate @text as usual (without any truncation, and put all your column-width processing into the printing section after the while loop. Calculate the sum of the lengths of text, determine how wide each column can be, and then format all your output accordingly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Feedback request for text file manipulator
by NovMonk (Chaplain) on Mar 26, 2004 at 21:09 UTC |