in reply to Assignment and printing at same time?

You can also print the assignment:
print $str = <<SEP; This is a string $xyz SEP
As other people have suggested, you often should be scoping the string with my when you assign it. What that does is well-explained by Dominus in Coping with Scoping.