|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: Corrupt Data?by friedo (Prior) |
| on Jul 14, 2008 at 19:41 UTC ( #697547=note: print w/ replies, xml ) | Need Help?? |
|
The reason you're getting garbage at the end of your loop is because you're pushing stuff onto @array, then shifting stuff off the front, but looping over @array sequentially. You can't alter the thing you're looping over and expect sane results. BTW, you don't need to use a C-style for loop to iterate over an array, it's much easier to write it this way: You also don't need to reset @hold each time through the loop if you declare it with my, since it will be lexically scoped to the enclosing block. You'll catch a number of other problems if you turn on strict and warnings; put this at the top of your script: and fix stuff until it stops yelling at you. Finally, the print @array statement at the end of your sub will never get executed because you return on the previous line! I think that should be enough to get you well on your way. Good luck!
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||