in reply to String replace, another question
As to the problem (as stated in the OP when I read it just now), this is not that different from the last thread you started -- did you happen to try the suggestions given there? (If yes, why not show what you tried? If not, why didn't you even try?)
I'd suggest something like this, IF you are confident that the xml input data is consistent enough to do it this way, without an xml parser (that is, the tags always show up on separate, consecutive lines, as shown in the OP) -- this applies one of the suggestions given by moritz in your previous thread:
That'll work as a simple stdin-stdout filter:my $change_next; while (<>) { if ( /<binddn>cn=xyzzz</ ) { $change_next = 1; } elsif ( $change_next and /<bindpass>welcome1</ ) { s/1/123/; $change_next = undef; } print; }
perl name_of_script < old_file.xml > new_file.xml
|
|---|