"here I tryed to make a sum. with "my $n= "$val+8";", so that I can obtain a vlue like -31.9999400000 (instead of '-39.9999400000'+8). But unfortunately that does not work. So how can I solve this problem? (that was the reason why I thought it is a string value)."

I know you've only been using Perl for a short amount of time, but I don't think you've really got an understanding of the basics. Try reading "perlintro -- a brief introduction and overview of Perl": you need a solid foundation on which to build further knowledge.

With regard to your "$val+8" question, this code should explain why it's not working:

#!/usr/bin/env perl -l use strict; use warnings; my @items = (-39.9999400000); my $val = $items[-1]; print $val; my $n = "$val+8"; print $n; my $x = $val+8; print $x;

Output:

-39.99994 -39.99994+8 -31.99994

-- Ken


In reply to Re^4: string to number via data dumper by kcott
in thread string to number via data dumper by semipro

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.