I'm wondering if the OP text got updated after the first few replies were posted... Updating your post is okay, but you really should preserve the original content (e.g. put
<strike>...</strike> around stuff to mark it as deleted), and point out what parts have been newly added. It helps to keep the discussion coherent.
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:
my $change_next;
while (<>) {
if ( /<binddn>cn=xyzzz</ ) {
$change_next = 1;
}
elsif ( $change_next and /<bindpass>welcome1</ ) {
s/1/123/;
$change_next = undef;
}
print;
}
That'll work as a simple stdin-stdout filter:
perl name_of_script < old_file.xml > new_file.xml
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.