in reply to While behavior
I just want to preserve $_ deeper within the while{} block
The code shown has no effect on $_. Did you mean $1? If so, I can’t see any problem with using $1 at the top of the loop, then redefining it lower down as needed. However, if you do want to dispense with $1, you could use a named capture:
while ($data =~ /^(?<line>.*)$/gm) { print "<3>" . $+{line} . "\n"; }
See Capture groups.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: While behavior
by SavannahLion (Pilgrim) on Feb 15, 2014 at 04:55 UTC |