You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As explained in https://github.com/quattor/configuration-modules-grid/pull/86/files#diff-1ed12f02554370943ea6fe0a5944b63f, there are circumstances where you want to match lines in a file using a regexp and to modify something in the matched lines but without knowing the exact contents of the matched lines. An example is when you want to comment some lines in a configuration file that matches a certain pattern. For this you need to be able to pass variables like $1 or $+{groupname} in the newline argument and get them evaluated. I don't have the feeling that the current replace() allows this...
The text was updated successfully, but these errors were encountered:
seems like a useful addition.
one question/proposal: the newvalue is currently a string, we could make a it an arrayref such that the matched position groups are zipped (like python zip) with the newvalue arrayref, like $linere = qr{a(B)c(D)} and newvalue ['x', 'y', 'z'] would retrun newvalue string xByDz
(in your example, this would become linre = qr{^(.*the line i want.*)$} and newvalue ['#',''])
does that seem userfriendly enough? (keeping newvalue as a string and eval'ing it would be another solution, but that sounds dangerous to do)
some remarks
a. word of caution on $+{groupname}, that is not supported in perl 5.8.8 (ie EL5)
b. you can already insert characters in text on arbitrary locations using fileeditor, but it's not userfriendly
As explained in https://github.com/quattor/configuration-modules-grid/pull/86/files#diff-1ed12f02554370943ea6fe0a5944b63f, there are circumstances where you want to match lines in a file using a regexp and to modify something in the matched lines but without knowing the exact contents of the matched lines. An example is when you want to comment some lines in a configuration file that matches a certain pattern. For this you need to be able to pass variables like
$1
or$+{groupname}
in the newline argument and get them evaluated. I don't have the feeling that the current replace() allows this...The text was updated successfully, but these errors were encountered: