$rtf isn't a string. It's a RTF::Writer object created by the call to RTF::Writer->new_to_file(). Your problem isn't with references, so your search is bound to end in frustration. Perhaps you could explain what you're really trying to accomplish? Is it that you don't want to write output to a file? If so you can look at the RTF::Writer documentation which provides a way for you to send the output to a string instead with RTF::Writer->new_to_string(). Afterward, you can do whatever you like with the string.