in reply to Re: Wizardv1.1
in thread Wizardv1.1
You put my $dmg inside the if block. The my part tells it that when that block ends at the next } to destroy your $dmg variable. In other words teh my part tells it that the variable $dmg should only be available for the current block. To fix it add my $dmg; outside the if and remove the my from inside the block.
my $dmg; if($room==6){ $dmg=int (rand 5)+1; }elsif($room==3){ $dmg=int (rand 4)+1; }elsif($room==2){ $dmg=int (rand 3)+1; }elsif($room==1){ $dmg=int (rand 2)+1; }
That might be better written as
my $dmg = int (rand $room + 1) + 1;
|
---|