I'm very new to perl, and I'm having trouble with the following script:
How do I write this so that when I change the value of "$firstnum" or "$secondnum", "$total" will also change - without me re-writing "$total = $firstnum + $secondnum;"?
Code:
#!perl
$firstnum = 3;
$secondnum = 2;
$total = $firstnum + $secondnum;
print $total; ##comes out to 5
$firstnum = 6;
print $total; ##comes out to 5 (I know why) - but I want to come out to 8
How do I write this so that when I change the value of "$firstnum" or "$secondnum", "$total" will also change - without me re-writing "$total = $firstnum + $secondnum;"?