Zombie has asked for the wisdom of the Perl Monks concerning the following question:
@achievement = ('level A1', 'level A2', 'level A3', 'level A4', 'level A5', 'level B1' , 'level B2', 'level B3', 'level B4', 'level B5', 'level C1' , 'level C2', 'level C3', 'level C4', 'level C5 +', ); while (@achievement) { my $level = shift @achievement; push (@result, $level); print "Result: @result\n"; }
For the above code, how do I modify the code to wipe out the value of @level when it hit "level 5" ? I want the output to be like
Meaning that once it hit level 5, it will wipe out the old values and print the new level until it hit level 5 again and wipe out the old values again.Result: Level A1 Result: Level A1 Level A2 Result: Level A1 Level A2 Level A3 Result: Level A1 Level A2 Level A3 Level A4 Result: Level A1 Level A2 Level A3 Level A4 Level A5 Result: Level B1 Result: Level B1 Level B2 Result: Level B1 Level B2 Level B3 Result: Level B1 Level B2 Level B3 Level B4 Result: Level B1 Level B2 Level B3 Level B4 Level B5
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wiping Out Values
by Chady (Priest) on May 26, 2001 at 10:31 UTC | |
|
Re: Wiping Out Values
by the_slycer (Chaplain) on May 26, 2001 at 10:32 UTC | |
by tadman (Prior) on May 26, 2001 at 12:52 UTC |