in reply to Returning and passing data to and from subroutines
while (@data) { $data[$loop_count] =~ m{s/^\s*//}xms; $data[$loop_count] =~ m{s/\s*$//}xms; $loop_count++; }
In addition to what toolic said, your loop would never end, as the condition tests the number of elements in the array, which doesn't change in the loop never becomes zero/false.
You probably want (though I'm not really sure what the substitutions are meant to do — what's the idea behind the /xms?)
for (@data) { # remove leading/trailing whitespace s/^\s*//; s/\s*$//; }
The current value being iterated over is aliased to $_, which allows you to change the original values by modifying $_.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Returning and passing data to and from subroutines
by jethro (Monsignor) on Jul 07, 2010 at 23:45 UTC | |
by almut (Canon) on Jul 07, 2010 at 23:59 UTC | |
by jethro (Monsignor) on Jul 08, 2010 at 08:16 UTC | |
by vendion (Scribe) on Jul 13, 2010 at 15:33 UTC |