in reply to argument isn't numeric in sprintf

You are falling prey to locale settings. You seem to have a German (or maybe other) locale where the decimal separator is "," (comma) not "." (dot). You will have to convert the data after you pull it out of Excel before you can work with it further:

use strict; use warnings; use Math::Round; my $rnd=Math::Round::Var->new (0.001); my $frsmt = $mtbf_data[3]; # use "$" instead of "@" if you only extrac +t one value of that row $frsmt =~ tr[.][]d; # eliminate all dots from the number $frsmt =~ tr[,][.]d; # turn all commas into dots $rounded_percent_frsmt=$rnd->round($frsmt); print "$rounded_precent_frsmt\n";

You should really, really get into the habit of using strict, because the code you posted didn't make much sense with the differing variable names ($frsmt vs. $precent_frsmt).

Replies are listed 'Best First'.
Re^2: argument isn't numeric in sprintf
by jwkrahn (Abbot) on Jul 19, 2007 at 19:49 UTC
    $frsmt =~ tr[.][]d; # eliminate all dots from the number $frsmt =~ tr[,][.]d; # turn all commas into dots

    You have specified the /d option on the second tr/// but you aren't deleting anything.

    You can combine both statements with a single tr///:

    $frsmt =~ tr[,.][.]d; # eliminate all dots from the number and turn al +l commas into dots
Re^2: argument isn't numeric in sprintf
by henrik (Initiate) on Jul 19, 2007 at 13:00 UTC
    it works!! thanks a lot for your help