This worked with the sample data. It uses strict and warnings. There are 5 additional lines and changes to 4 lines. Otherwise, the code is the same as yours. Not saying there may be better ways.  :-)
#!/usr/bin/perl use strict; use warnings; my @data; # new addition my $max = 0; # new addition while (<DATA>) { chomp; # new change next unless /\S/; # new change my $string = $_; # new change $string =~ s/,000//g; $string =~ s/,//g; my @numbers= $string =~ /(\d+)/g; my $f= $numbers[0]; my $s= $numbers[1] || 0; # new change my $isf9 = substr($f,-3); if ($isf9 =~/999/) {$f=$f + 1;} my $iss9 = substr($s,-3); if ($iss9 =~/999/) {$s=$s + 1;} $f =~ s/000//g; $s =~ s/000//g; my $fac; if ($f>0 && $s>0){ $fac = (($s-$f)/2)+$f;} if ($f>0 && $s<1){ $fac = $f;} if ($fac>0) { my $length = length($fac); # new addition $max = $length if $length > $max; # new addition $_ =~ s/^/($fac) /; $_ =~ s/$/;fac=$fac/; } push @data, $_; } # new addition print map {s/\((.+?)\)/ sprintf "(%$max.1f)", $1/e; "$_\n"} @data; __DATA__ Less than $10,000 $10,000 to less than $20,000 $20,000 to less than $30,000 $30,000 to less than $40,000 $40,000 to less than $50,000 $50,000 to less than $60,000 $60,000 to less than $70,000 $70,000 to less than $80,000 $80,000 to less than $90,000 $90,000 to less than $100,000 $100,000 to less than $125,000 $125,000 to less than $150,000 $150,000 or higher

In reply to Re: Info based on total changes by Anonymous Monk
in thread Info based on total changes by pqocpiha

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.