in reply to Pattern Matching

Hi

my underdastanding is that ".*?" eats up much more than you want it to,
because the overall match has to succeed. It can match without giving up
the initial match of  <index-entry id= and therfore it will.

if you change it to
$str =~ s#<index-entry id="[^"]*"><index-heading></index-heading>\n</i +ndex-entry>##gsi;

it should work.
But this looks like XML of some kind so maybe your better off using a
module for this kind of tasks anyway?
si_lence