Perl and nested loop substitution
Hello! I have a trouble with getting Perl to substitute a regular expression in a nested loop. The construction is like this:
Code:
for ($i=11; $i<=99; $i++) { Please tell me, why this is the case? Many thanks. Evgeniy |
Your inner loop substitutes 11 for every 10 found in @input
So the next time the outer loop runs, and increments i, all the matches and substitutions have already been done, There will never be a 10 to match in the inner loop after the first run. The if statement is never true. The printed i is always 11. example containing 3 x 10, and showing the array after each pass of the inner loop. Code:
#!/usr/bin/perl Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 10 98 15 13 10 |
Thanks a lot! I have confused myself
|
All times are GMT -5. The time now is 09:37 AM. |