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:my @results; foreach my $addr( @array ) { my $element = lc $addr; # mess with $element here push @results, $element; } return @results;
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!use strict; use warnings;
I think that should be enough to get you well on your way. Good luck!
In reply to Re: Corrupt Data?
by friedo
in thread Corrupt Data?
by spickles
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |