sub write { @_ == 3 or croak 'Usage: $sftp->write($fh, $data)'; my ($sftp, $rfh) = @_; $sftp->flush($rfh, 'in') or return undef; utf8::is_utf8($_[2]) and croak "write method can not handle UTf8 data"; ...