use Modern::Perl; {local $/="\n\n"; while (<DATA>) { s{<bindpass>welcome1</bindpass>}{<bindpass>welcome123</bindpass +>} if m{^<binddn>cn=xyzzz</binddn>}; print; } } __DATA__ <binddn>cn=abcde</binddn> <bindpass>welcome1</bindpass> <binddn>cn=abcde</binddn> <bindpass>welcome1</bindpass> <binddn>cn=xyzzz</binddn> <bindpass>welcome1</bindpass>
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: String Manipulation
by CountZero
in thread String replace, another question
by heeru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |