in reply to replace comma for dot re. calculation

Bitten by over thinking the plumbing. Change the colsMap line to:

$table->colsMap( sub {$_->[0] =~ s/,/\./g; $_->[2] = $_->[0] * $_->[1] + } );

and the code prints:

Numbers,Values,Result 100.20,2,200.4 18.20,3,54.6 19.45,2,38.9 7.25,2,14.5

which I suspect is what you were after.

The result of $_->[0] =~ s/,/\./g is true (1) if there was a match. You were expecting the resulting value of $_->[0] perhaps?


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: replace comma for dot re. calculation
by GertMT (Hermit) on Jun 22, 2007 at 10:01 UTC
    Multiplying Numbers * Values or column 0 times column 1 is indeed where I was after. I kept getting 1 or nothing as a result. I'm very happy with this, it is indeed where I was after! I understand I have to first do the replace and then the calculation.
    Thanks again.