in reply to Re^2: return undef
in thread return undef

Ah, you've confused people with your terminology. You seem to mean that the function reads from a filehandle and returns the contents. Is this correct?

If so, something like:

my $filedata = myfunction(); if (defined $filedata) { print FILEHANDLE $filedata; } else { # handle error... }
P.S. Showing some or all of myfunction() would really help us help you.