in reply to messing up $line?

I would say the second if (er, elsif in this case) isn't going to fire if the first if actually does a replacement. So no...

If they were separate if statements, then yes (possibly). I don't believe the string is ever altered unless an actual replacement happens.

-Paul