in reply to Re^2: results printing error
in thread results printing error

Is this (an outrageously simplified version of ) what you want?

#!/usr/bin/perl use strict; use warnings; print STDOUT sub1(); sub sub1 { my $string = "foo bar \n"; $string .= $string; }

Season to taste with an appropriate filehandle and sub.
  "taste" may improve with a hearty helping of perldoc...