Hi all,

I've got a file with weird numbers that need to be reformatted. Here's a line from the file:
1 1 4 1 0.225120000000000D+06 0.341913000000000D+07 1 1 1 661 660 660 +659
I need to take the large numbers, add 30 to one of them, and then print them back out in a "normal" format. Here's what I have so far:
#!/usr/sbin/perl -w use strict; ... if (/^\s+1/) { @info = split(' ', $_, 9999); $my_x = $info[4] + 0; $my_y = $info[5] + 30; for($i = '1'; $i <= $info[2]; $i++) { print ("$my_x $my_y $info[($i + 8)]\n"); $my_y = $my_y + 30; } } ...
So far it works...kind of. Here's the output:
Argument "0.225120000000000D+06" isn't numeric in addition (+) at H:\d +em2xyz.pl line 33, <FILE> line 2. Argument "0.341913000000000D+07" isn't numeric in addition (+) at H:\d +em2xyz.pl line 34, <FILE> line 2. 225120 3419160 661 225120 3419190 660 225120 3419220 660 225120 3419250 659 Argument "0.225150000000000D+06" isn't numeric in addition (+) at H:\d +em2xyz.pl line 33, <FILE> line 3. Argument "0.341913000000000D+07" isn't numeric in addition (+) at H:\d +em2xyz.pl line 34, <FILE> line 3. 225150 3419160 661 225150 3419190 659 225150 3419220 660
It seems to always give me a warning the first time it tries to print the large numbers. After that, it doesn't seem to mind. Is there a way to convert the numbers in weird notation to their non-decimal counterparts without an error?

Thanks!
^l9v

In reply to Weird number formatting by licking9Volts

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.