chickenlips has asked for the wisdom of the Perl Monks concerning the following question:
Basically, I have a set of scores that will be pushed into an array each time the program loops (i.e. the person says they want to play again)
This is my code so far:
It is worth noting that the variable $score_total is the score from an earlier bit of code, every time this bit finishes and the $score_total is pushed into @score_array, the $score_total gets intialized to 0 again so a new score can be added. How can I go about putting this in a high scores table that is displayed as the above code part : print "Name = $initials_array[0]\tScore = $score_array[0]\n"; I want it to add the scores each time the game is played so that the high scores table gets more populated. THANKS IF ANYONE CAN HELP!!print "Your final score is: $score_total\n\n"; # score organiser. print "Please enter your initials for the high score table: \n"; chomp (my $initial_add = <STDIN>); my @initials_array = (); push (@initials_array, $initial_add); my @score_array = ($score_total); push (@score_array, $score_total); print "Name = $initials_array[0]\tScore = $score_array[0]\n"; print "Initials \t Score \n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Making a dynamic high scores table
by Athanasius (Archbishop) on Dec 01, 2012 at 16:14 UTC | |
Re: Making a dynamic high scores table
by roboticus (Chancellor) on Dec 01, 2012 at 17:20 UTC | |
Re: Making a dynamic high scores table
by space_monk (Chaplain) on Dec 01, 2012 at 16:32 UTC | |
Re: Making a dynamic high scores table
by kcott (Archbishop) on Dec 02, 2012 at 08:35 UTC | |
Re: Making a dynamic high scores table
by Anonymous Monk on Dec 01, 2012 at 15:30 UTC | |
Re: Making a dynamic high scores table
by Anonymous Monk on Dec 01, 2012 at 15:43 UTC |
Back to
Seekers of Perl Wisdom