in reply to Re^4: Perl can't make some easy arithmetics :(
in thread Perl can't make some easy arithmetics :(
Yes, unless one of the variables has already been coerced to be a bigint, so even this is enough:
use bigint; while(<>) { my ($a, $b)= split/ /; $a += 0; print $a - $b, "\n"; }
However you can just coerce everything when you first read them in as strings:
use bigint; while(<>) { my ($a, $b)= map { 0+$_ } split/ /; print $a - $b, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Perl can't make some easy arithmetics :(
by no_slogan (Deacon) on Oct 24, 2014 at 22:19 UTC | |
|
Re^6: Perl can't make some easy arithmetics :(
by LanX (Saint) on Oct 24, 2014 at 22:21 UTC | |
by rsFalse (Chaplain) on Oct 25, 2014 at 00:27 UTC | |
by AnomalousMonk (Archbishop) on Oct 25, 2014 at 00:37 UTC | |
by rsFalse (Chaplain) on Oct 25, 2014 at 00:55 UTC | |
by rsFalse (Chaplain) on Oct 26, 2014 at 17:25 UTC | |
by syphilis (Archbishop) on Oct 27, 2014 at 02:17 UTC | |
by LanX (Saint) on Oct 26, 2014 at 17:57 UTC |