http://qs1969.pair.com?node_id=214518


in reply to search and replace is not working as expected...

I believe you want this:

$ARRGH =~ s#<doct>Customer trans\.(?:.*)+?</doct>#<doct>Customer trans\.</doct +>#g;

What the +? does is makes the match less "greedy", so that it matches the first </doct> it finds instead of the last. Also, since you aren't using what you capture in (.*), I put the ?: in, so that perl doesn't try to retain what it found, but still keeps the grouping.

I also changed the regex delimiter to | so that you don't have to escape the / in </doct>.

Update: As per Aristotle's reply, I've changed the regex delimiter to #.