We would really need to see a data sample to know and figure out. In general, using regexes for manipulating numbers is not a very good idea (except of course just picking up the number in a string), but there can be many exceptions, especially when reading from a file. In general, if the numbers can be read as a number by Perl straight out of the box, you probably want to let Perl convert it into a number and then apply your sprintf format to all of them. But, then, again, there can be exceptions, so please show a smple of your data.

Update: Hum, just reading your post again just immediately after having posted, I realize that I had not understood that your letters referred to the metric system prefixes. Forget what I wrote above, it is most probably irrelevant to your problem. Sorry for having misread your problem.


In reply to Re: Doing multiple search and replace operations on a string by Laurent_R
in thread Doing multiple search and replace operations on a string by letssee

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.