Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Making a dynamic high scores table

by Athanasius (Chancellor)
on Dec 01, 2012 at 16:14 UTC ( #1006612=note: print w/replies, xml ) Need Help??

in reply to Making a dynamic high scores table

When you declare a variable with my, you initialise it. If you do this inside a loop, the variable is re-initialised on each loop iteration. But if you want the variable to grow as the loop iterates, you need to declare it once only, before the loop:

my @initials; my @scores; while (...) # The major loop { ... push @initials, $initial_add; push @scores, $score_total; ... } # access @initials and @scores here

Hope that helps,

Athanasius <°(((><contra mundum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006612]
[Corion]: Hi marto!
[Corion]: I hope you were able to catch up on some sleep
Corion is slowly, slowly relaxing. Yesterday I spent vegging out in front of the PC, today at a friends, and hopefully I have the books for our Perl club done by Monday. I guess I'll only really relax once I get back from LPW

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-11-19 11:21 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (279 votes). Check out past polls.