almr has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
what's an idiomatic way to match certain regions of a string (m//mg), and then for each sub-region, perform substitutions (s///mg)? I can think of several options, none of which seems appealing.
E.g. within regions delimited by "# START" / "# END", uncomment lines (s/^[ #]*//g). I could turn the string into a line-list, use the flip-flop to identify regions, and s///g for each line. But isn't there something cleaner and more general?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: s///g within m//g regions
by haukex (Archbishop) on Nov 09, 2021 at 14:22 UTC | |
by almr (Sexton) on Nov 09, 2021 at 21:52 UTC | |
Re: s///g within m//g regions
by ikegami (Patriarch) on Nov 09, 2021 at 13:48 UTC | |
by almr (Sexton) on Nov 09, 2021 at 15:52 UTC | |
by ikegami (Patriarch) on Nov 10, 2021 at 17:31 UTC | |
Re: s///g within m//g regions
by tybalt89 (Monsignor) on Nov 09, 2021 at 14:16 UTC | |
Re: s///g within m//g regions
by LanX (Saint) on Nov 09, 2021 at 13:14 UTC | |
by almr (Sexton) on Nov 09, 2021 at 13:21 UTC | |
by LanX (Saint) on Nov 09, 2021 at 13:25 UTC | |
by almr (Sexton) on Nov 09, 2021 at 13:32 UTC | |
by hippo (Bishop) on Nov 09, 2021 at 13:50 UTC | |
by LanX (Saint) on Nov 09, 2021 at 14:11 UTC | |
by LanX (Saint) on Nov 09, 2021 at 20:30 UTC | |
| |
by almr (Sexton) on Nov 11, 2021 at 13:23 UTC | |
by hippo (Bishop) on Nov 11, 2021 at 16:00 UTC | |
by LanX (Saint) on Nov 11, 2021 at 17:05 UTC |
Back to
Seekers of Perl Wisdom