in reply to maths-thing

You can use the power of eval to get rid of this block:
if ($x == "0"){ $num_c = $num_a + $num_b } if ($x == "1"){ $num_c = $num_a - $num_b } if ($x == "2"){ $num_c = $num_a * $num_b }
like so:
# ... my $equat = "$num_a $symbols[$x] $num_b"; print "$equat = "; # ... $num_c = eval $equat; # ...
And there is really nothing wrong with the way you store the high score, but you might be better off in the long run keeping a format like:
score:name
in case you want to keep a top 10 list - much easier to parse. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: maths-thing
by Gordy (Scribe) on Sep 02, 2002 at 13:43 UTC
    Thanks for the advice, I was looking for a better way of handling the way the sum was processed so your tip is most welcome. Regarding your suggestion of changing the high score file format to score:name .. I could then handle the file with something like ..
    #... open (FILE, "hi.dat") || die "cannot open file hi.dat\n"; while (<FILE +>) { chomp; ($hi_score,$name) = split(/:/); } close (FILE) || die "cannot close file hi.dat\n"; #...
    Gordy