in reply to Suggestion on rewriting small code
Note that your print could be written:
print "$str\n"; [download]
or with current versions of Perl:
say $str; [download]