gghelpneeded:

It's telling you that the string value "(49)" isn't numeric. Whenever you use a string as a number, perl tries to convert the string to a number using some simple rules. Usually it works just the way you want, but it can't possibly always do what you want.

Consider these examples:

$ cat x.pl #!/usr/bin/env perl use strict; use warnings; my @stuff = (49, (49), "49", "(49)", "123", "76 trombones", "123 E 31st", "123E31st street"); for my $t (@stuff) { print "t=<$t>, t+0=", $t+0, "\n\n"; } Roboticus@Waubli ~ $ perl x.pl t=<49>, t+0=49 t=<49>, t+0=49 t=<49>, t+0=49 Argument "(49)" isn't numeric in addition (+) at x.pl line 8. t=<(49)>, t+0=0 t=<123>, t+0=123 Argument "76 trombones" isn't numeric in addition (+) at x.pl line 8. t=<76 trombones>, t+0=76 Argument "123 E 31st" isn't numeric in addition (+) at x.pl line 8. t=<123 E 31st>, t+0=123 Argument "123E31st street" isn't numeric in addition (+) at x.pl line +8. t=<123E31st street>, t+0=1.23e+33

So if you really want to treat them as numbers, you'll need to come up with the appropriate rules (and code) to determine what number to convert them into. If it's as simple as stripping off parenthesis, you could do it with s/[()]//g, but be sure to think about all the special cases you may run into...

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: numbers in parentheses not considered numeric values?? by roboticus
in thread numbers in parentheses not considered numeric values?? by gghelpneeded

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.