Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl Maths

How do I do...

         

Luke1986

10:47 pm on Oct 19, 2001 (gmt 0)



Hi Everyone,

I've just started learning Perl and the maths part is confusing me.

Say I have $value, which is equal to 75 (or any integer), how would I perform mathematical sums on this? e.g. - + * /

oilman

10:53 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



math in perl is done exactly how you would expect:

$value = 75
$value2 = 25
$value3 = $value + $value2
$value4 = $value - $value2

this means $value3 = 100 and $value4 = 50

Luke1986

11:42 pm on Oct 19, 2001 (gmt 0)



Thanks Oilman,

I am getting the support I was promised, brilliant!

ggrot

1:55 am on Oct 20, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think += works as well in perl, for simplicity:

$value = 75
$value += 25

$value now contains 100.
the second line is equivalent to
$value = $value + 25