Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I don't think 'next' can't be modified as a scalar though...any ideas? Cheers! Stevieforeach $line (@lines) { if ($line =~m/^SY /) { $line =~s/^SY/CN/) if (next =~m/^SY /) { next =~s/^SY/ /; } } } # so if the first line starts 'SY' replace with 'CN', but if the next +after the replacement does, then change SY on the next line for ' '.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Modifying 'next' in foreach loop
by kyle (Abbot) on Apr 28, 2008 at 14:49 UTC | |
by GrandFather (Saint) on Apr 28, 2008 at 19:38 UTC | |
|
Re: Modifying 'next' in foreach loop
by apl (Monsignor) on Apr 28, 2008 at 14:40 UTC | |
|
Re: Modifying 'next' in foreach loop
by runrig (Abbot) on Apr 28, 2008 at 16:01 UTC | |
|
Re: Modifying 'next' in foreach loop
by mscharrer (Hermit) on Apr 28, 2008 at 15:33 UTC |