Assuming you want to replace password (in your example) with $usernewpwd, you need to make sure you preserve the "xdbns='jabber:iq:auth'>" and "<" parts, by including them in the replacement. So:
s/xdbns='jabber:iq:auth'>.*?</xdbns='jabber:iq:auth'>$usernewpwd</g;
or
s/(xdbns='jabber:iq:auth'>).*?(<)/$1$usernewpwd$2/g;
Note that I changed .* to .*?; this will cause it to prefer to stop matching at the first < instead of going on to a later < on the line.
Have you considered quoting issues? E.g. if a password actually contains a character like "<", what will whatever usually builds the file put there? And can you do it the same way to $usernewpwd, and adjust the regex to handle it?
It might be better to look to one of the fine XML modules available on CPAN, than do it by hand.
Update: And as Boris says, you need to make sure to actually write out the changed lines to a new file.
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.