in reply to Specifying filename
Obligatorily: use strict; use warnings;
You might want to chomp $filename to remove the newline at the end of the user-supplied data.
Linebreaks in your XML: the \n probably isn't doing what you want inside single-quotes. Try doublequotes?
Given that the text you're using already has double-quotes in it, you can get the same effect with the qq function: print qq{This is a string with "quotes" in it\n};