the numbers in parenthesis are the midpoint (if 2 numbers are present in the string). The fac= is a duplicate of that midpoint. If there's only 1 number in the string, then that one number is used for both the number in parenthesis as well as the fac= number.
while (<>) { chop; if ($_ =~/(.*)/) { $string = $1; $string =~ s/,000//g; $string =~ s/,//g; @numbers= $string =~ /(\d+)/g; $f= $numbers[0]; $s= $numbers[1]; $isf9 = substr($f,-3); if ($isf9 =~/999/) {$f=$f + 1;} $iss9 = substr($s,-3); if ($iss9 =~/999/) {$s=$s + 1;} $f =~ s/000//g; $s =~ s/000//g; #print join (" ",@numbers); if ($f>0 && $s>0){ $fac = (($s-$f)/2)+$f;} if ($f>0 && $s<1){ $fac = $f;} if ($fac>0) { $_ =~ s/^/($fac) /; $_ =~ s/$/;fac=$fac/; } } print "$_\n"; }

In reply to Re^2: Info based on total changes by pqocpiha
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.