[ Pobierz całość w formacie PDF ]
."\n");mkdirCategory: list operator (files)Arguments: filename, modeReturn value: 1 or 0Creates a directory with a name specified by the filename, with the mode specified by the octal mode.If it fails $OS_ERROR ($!) is set to operating system error.Example:print("mkdir() ",mkdir("/tmp/testdir",0777), "\n");msgctlCategory: list operator (System V)Arguments: id, cmd, argReturn value: specialEquivalent to the unix system call msgctl() if supported.msggetCategory: list operator (System V)Arguments: key, flagsReturn value: specialEquivalent to the unix system call msgget() if supported.msgrcvCategory: list operator (System V)Arguments: id, var.size, type, flagsReturn value: specialEquivalent to the unix system call msgrcv() if supported.msgsndCategory: list operator (System V)Arguments: id, msg, flagsReturn value: specialEquivalent to the unix system call msgsnd() if supported.myCategory: named unary operator (scope)Arguments: expressionReturn value: n/aDeclares each of the variables listed to be local() to the block.If more than one variable is specified parentheses are required.The may() specification is stronger than the the local() specification as it not only stops pollution of the global namespace, but creates a stack frame for subroutine calls so that recursive calls will behave as one would expect with local variables.nextCategory: named unary operator (flow)Arguments: labelArguments: noneReturn value: n/aExample:print("next ");@array = ("a","b","c");loop: foreach $elem (@array) {next if $elem =~ /^a/;print $elem;}print "\n";noCategory: list operator (module)Arguments: module, listReturn value: n/aUnimports values imported by use(), this is particularly useful when using pragmas:Example:use integer;# code using integer arithmetic hereno integer;# back to floating point arithmeticoctCategory: named unary operator (numeric)Arguments: expressionReturn value: numericThis function evaluates the expression as an octal string and returns the decimal value.Example:print("oct() ",oct("88"), "\n");openCategory: list operator (files)Arguments: handle, filenameArguments: handleReturn value: TRUE (non zero) or FALSE (undefined)This function opens a file using the specified file handle.The file handle may be an expression, the resulting value is used as the handle.If no filename is specified a variable with the same name as the file handle used (this should be a scalar variable with a string value referring to the file name).The file name string may be prefixed with the following values to indicate the mode "<" (read, this is the default), ">" (write), "+>" (read/write - starting with new file), "+<" (read/write using existing file) , ">>" (append), "<command> |" (input pipe - the file name is actually a subshell command from which the file handle is piped), "| <command>"(output pipe - the file name is actually a subshell command to which the output of the file handle is piped).The special file name '-' refers to STDIN '-' or STDOUT '>-'.Example:open(FIL,"/tmp/notexist") || print("open() failed as file did not exist.\n");opendirCategory: list operator (files)Arguments: handle, dirnameReturn value: TRUE/FALSEOpens a directory handle for the directory name specified.If the dirname is an expression this can be evaluated to return a name.Example:opendir (DIR, "/tmp/notexist") || print("opendir() diled as directory dod not exist.\n");ordCategory: named unary operator (string)Arguments: expressionArguments: noneReturn value: numericReturns the numeric ascii code of the first character in the expression (or $_ if none specified).Example:print("ord() ",ord("A"), "\n");packCategory: list operator (records)Arguments: template, listReturn value: stringReturns a packed version of the data in the list using the template to determine how it is coded.The template comprises a sequence of characters each specifying the data type of the matching data item in the list:@Null fill to absolute position.AAscii string with spaces to pad.aAscii string with nulls to pad.bBit string (ascending bit order).BBit string (descending bit order).cSigned char value.CUnsigned char value.dDouble-precision float in the native format.fSingle-precision float in the native format.hHex string (low nybble first).HHex string (high nybble first).iSigned integer value.IUnsigned integer value.lSigned long integer value.LUnsigned long integer value.nShort integer "network" order.NLong integer "network" order.pPointer to a null-terminated string.PPointer to a structure (fixed-length string).sSigned short integer value.SUnsigned short integer value.uUUencoded string.vShort integer "VAX" (little-endian) order.VLong integer "VAX" (little-endian) order.xNull byte.XBack up a byte.A concise form of template can be used by appending a number after any letter to repeat that format specifier.For aA the number uses one value and pads the rest.For bB the number indicates the number of bits.For hH the number indicates the number of nybbles.For P the number indicates the size of the pointer structure.Using a * in place of a number means to repeat the format specifier as necessary to use up all list values.Note that some packed structures may not be portable across machines (in particulat network and floating point formats).It should be possible to unpack the data using the same format specification with an unpack() call.Example:Use Socketl@a=(140,203,7,103);$addr=pack('C4',@a);($name,$alias,$adrtype,$length,@address)=gethostbyaddr($addr,AF_INET);print("pack() ",@a, "packed as: $addr"
[ Pobierz całość w formacie PDF ]