in reply to Contextual find and replace large config file
First let me warn you that your code has an error
This will fail if you don't care about indentation:
if ( $line =~ /ObjectType1/ ) { $context = "ObjectType1" ; } if ( $line =~ /\}/ ) { $context = "" ; }
Here you rather want to test for /$\}/ at lines start!
My suggestions
Like this you will get reusable and maintainable code!
some may miss example code, but you got a generic answer for a generic question.
Feel free to pick some points and ask for clarification.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Contextual find and replace large config file
by Veltro (Hermit) on Jan 03, 2019 at 11:06 UTC | |
by LanX (Saint) on Jan 03, 2019 at 14:49 UTC |