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

In reply to How can you save some data? by Sismetic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.