in reply to returning data from a for() loop?
If you want to return an array from a loop, either accumulate it, or use a function that returns one (map, grep, split, etc.). Your scroll() routine could be better written as something like:
if you're trying to return an array that alternates between input characters and newlines, orsub scroll { map { $_, "\n" } split('', shift) }
if you're trying to return an array of strings that have successive characters from the argument ending with newlines. It wasn't clear which you wanted.sub scroll { map { "$_\n" } split('', shift) }
update: added clarification
|
|---|