My suggestion, such as it is, would be first to initialize your $temp var ala:
my $temp = "";
Second, I would suggest within your while loop:
while ( <> ) {
$temp .= $_."\n";
}
--SparkyG
UPDATE
Added
<> to the while loop condition. I was just furthering someone else's errors.
--SparkeyG