in reply to Re: numbers in parentheses not considered numeric values??
in thread numbers in parentheses not considered numeric values??

thanks for that example, further solidifying the explanation above. Both examples get the point across greatly!

when you speak of stripping off parenthesis do you mean through the code itself or the find and replace feature on gedit?

  • Comment on Re^2: numbers in parentheses not considered numeric values??

Replies are listed 'Best First'.
Re^3: numbers in parentheses not considered numeric values??
by roboticus (Chancellor) on Aug 08, 2015 at 03:21 UTC

    gghelpneeded:

    As the Anonymous Monk mentioned, in your code. Different sources of data may have different quirks, so you need to know about your data source to figure out the best way to clean up the data. You want to be careful with your fixes, though, to make sure you make the appropriate conversions.

    For example, in some accounting reports, parenthesis around a number may indicate that it's negative value rather than positive. Other systems may include commas, currency symbols or other formatting information. Yet other systems use a trailing sign on the data. Once you find out all the quirks, you shouldn't have too much trouble writing an appropriate subroutine to clean up and convert the data to the form you need.

    ...roboticus

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

Re^3: numbers in parentheses not considered numeric values??
by Anonymous Monk on Aug 07, 2015 at 23:10 UTC

    In the code itself, see example below:

    #!/usr/bin/perl -l # http://perlmonks.org/?node_id=1137878 use strict; use warnings; $| = 1; while(<DATA>) { my @value = split; tr/()//d for @value; # THE FIX print $value[1] - $value[0]; } __DATA__ (15) 20 (3) 50