my $msg = ; open(my $msg_fh,"<",\$msg) or die "Couldn't create scalar filehandle: $!\n"; my $file = "msg_".time.".txt"; # ... $host->put($msg_fh,$file) or die "cannot put file: ", $host->message, $/;