Is there a way to give equal field spacing of thirty characters in each field of data in front of the comma?
For example: (30 - field data) = additonal spacing
Needed Output:
Ent , Name ,
SCO11 , RUN ,
Current Data:
Ent, Name,
SCO11, RUN,
Ent, Name,
NA932, TAKE,
I wrote the following code for equal spacing:
$counter = 0;
foreach(@newstuff){
$counter++;
if(m/Ent/){
$counter=0;}
if(m/Payor/){
if($counter > $hold){
$hold = $counter; }
}
}
$counter2 = 0;
foreach(@newstuff){
$counter2++;
if(m/Ent/){
$counter2=0;}
if(m/Payor/){
if($counter2 < $hold){
$temp = $counter2;
for($temp;$temp < $hold; $temp++){
#for($j=0;$j < $hold; $j++){
s/Payor/\nPayor/;
}
}
}
}
How can I make the file have equal field spacing?
There has be be a was to count the contents of each line in the array and add, assuming staticval = 30, spaces before the commas of each field minus the charater in each field.
In example, "Ent," would turn out to be staticval minus the number of characters found in Ent. This would be Ent followed by twenty-seven spaces and a comma.
updated by boo_radley : formatting, code tags
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.