in reply to
- s/foore/barstring/ works on $_ in isolation, but you're not setting $_, even implicitly.
- You set $doc but never subsequently refer to it.
- You use IO::File but never subsequently refer to it.
- You alternate between slashes and hashes for regexp delimiters for no apparent reason
- Looks like your input XML is not valid XML
- and finally, you both use an XML parser and then attempt to just regexp your way through the string. Pick one, not both.