require 'syscall.ph'; # may need to run h2ph syscall(&SYS_write, fileno(STDOUT), "hi there\n", 9);
Note that Perl supports passing of up to only 14 arguments to your system call, which in practice should usually suffice.
Syscall returns whatever value returned by the system call it calls. If the
system call fails, syscall returns -1 and sets
$! (errno). Note that some system calls can legitimately return -1. The proper
way to handle such calls is to assign
$!=0; before the call and check the value of <$!> if syscall returns -1.
There's a problem with syscall(&SYS_pipe): it returns the file number of the read end of the pipe it creates. There is no way to retrieve the file number of the other end. You can avoid this problem by using pipe instead.