Dear Monks,
I am REALLY new in Perl(btw im new in everything about programming),in fact i've only started to write code 3 or so days ago.And I was wondering if any of you could help me,because I have a piece of code:
sub Char{
my $char=400;
my $hp= $char - int(rand(20));
print $hp ;
}
print Char();
The purpose of this (tiny) piece of code is to make a "character" lose hitpoints between numbers 0-20, he is going to start with 400 hitpoints,and lose randomly from 0-20 hitpoints per turn.The problem is idk how to have Perl save that piece of data,so as when it loses for example 20, he will have 380,but then when i print it again it shows 398 for example,instead of 380 - int(rand(20)).
Thanks for your answers and helping me