Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Reset default output or do I/O ...Fixed-length unbuffered input ... (Berikutnya)
Input and output functions

Execute an arbitrary system call

Daftar Isi

  • syscall NUMBER, LIST

    Calls the system call specified as the first element of the list,passing the remaining elements as arguments to the system call. Ifunimplemented, raises an exception. The arguments are interpretedas follows: if a given argument is numeric, the argument is passed asan int. If not, the pointer to the string value is passed. You areresponsible to make sure a string is pre-extended long enough toreceive any result that might be written into a string. You can't use astring literal (or other read-only string) as an argument to syscallbecause Perl has to assume that any string pointer might be writtenthrough. If yourinteger arguments are not literals and have never been interpreted in anumeric context, you may need to add 0 to them to force them to looklike numbers. This emulates the syswrite function (or vice versa):

    1. require 'syscall.ph'; # may need to run h2ph
    2. $s = "hi there\n";
    3. syscall(&SYS_write, fileno(STDOUT), $s, length $s);

    Note that Perl supports passing of up to only 14 arguments to your syscall,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 properway to handle such calls is to assign $!=0 before the call, thencheck the value of $! if syscall returns -1.

    There's a problem with syscall(&SYS_pipe): it returns the filenumber of the read end of the pipe it creates, but there is no wayto retrieve the file number of the other end. You can avoid thisproblem by using pipe instead.

    Portability issues: syscall in perlport.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Reset default output or do I/O ...Fixed-length unbuffered input ... (Berikutnya)