sprintf

sprintf FORMAT, LIST Returns a string formatted by the usual printf conventions of the C library function sprintf. See below for more details and see sprintf(3) or printf(3) on your system for an explanation of the general principles. For example: # Format number with up to 8 leading zeroes $result = sprintf("%08d", $number); # Round number to 3 digits after decimal point $rounded = sprintf("%.3f", $number); Perl does its own sprintf formatting: it emulates the C function sprintf(3), but does

split

split /PATTERN/,EXPR,LIMIT split /PATTERN/,EXPR split /PATTERN/ split Splits the string EXPR into a list of strings and returns the list in list context, or the size of the list in scalar context. If only PATTERN is given, EXPR defaults to $_ . Anything in EXPR that matches PATTERN is taken to be a separator that separates the EXPR into substrings (called "fields") that do not include the separator. Note that a separator may be longer than one character or even have no characters at all (the em

splice

splice ARRAY,OFFSET,LENGTH,LIST splice ARRAY,OFFSET,LENGTH splice ARRAY,OFFSET splice ARRAY splice EXPR,OFFSET,LENGTH,LIST splice EXPR,OFFSET,LENGTH splice EXPR,OFFSET splice EXPR Removes the elements designated by OFFSET and LENGTH from an array, and replaces them with the elements of LIST, if any. In list context, returns the elements removed from the array. In scalar context, returns the last element removed, or undef if no elements are removed. The array grows or shrinks as necessary. If OF

sort - perl pragma to control sort() behaviour

NAME SYNOPSIS DESCRIPTION CAVEATS NAME sort - perl pragma to control sort() behaviour SYNOPSIS use sort 'stable'; # guarantee stability use sort '_quicksort'; # use a quicksort algorithm use sort '_mergesort'; # use a mergesort algorithm use sort 'defaults'; # revert to default behavior no sort 'stable'; # stability not important use sort '_qsort'; # alias for quicksort my $current; BEGIN { $current = sort::current(); # identify prevailing algorithm } DESCRIP

sort

sort SUBNAME LIST sort BLOCK LIST sort LIST In list context, this sorts the LIST and returns the sorted list value. In scalar context, the behaviour of sort() is undefined. If SUBNAME or BLOCK is omitted, sorts in standard string comparison order. If SUBNAME is specified, it gives the name of a subroutine that returns an integer less than, equal to, or greater than 0 , depending on how the elements of the list are to be ordered. (The <=> and cmp operators are extremely useful in such rout

socketpair

socketpair SOCKET1,SOCKET2,DOMAIN,TYPE,PROTOCOL Creates an unnamed pair of sockets in the specified domain, of the specified type. DOMAIN, TYPE, and PROTOCOL are specified the same as for the syscall of the same name. If unimplemented, raises an exception. Returns true if successful. On systems that support a close-on-exec flag on files, the flag will be set for the newly opened file descriptors, as determined by the value of $^F. See $^F in perlvar. Some systems defined pipe in terms of socket

Socket - networking constants and support functions

NAME SYNOPSIS DESCRIPTION CONSTANTSPF_INET, PF_INET6, PF_UNIX, ... AF_INET, AF_INET6, AF_UNIX, ... SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, ... SOCK_NONBLOCK. SOCK_CLOEXEC SOL_SOCKET SO_ACCEPTCONN, SO_BROADCAST, SO_ERROR, ... IP_OPTIONS, IP_TOS, IP_TTL, ... IPTOS_LOWDELAY, IPTOS_THROUGHPUT, IPTOS_RELIABILITY, ... MSG_BCAST, MSG_OOB, MSG_TRUNC, ... SHUT_RD, SHUT_RDWR, SHUT_WR INADDR_ANY, INADDR_BROADCAST, INADDR_LOOPBACK, INADDR_NONE IPPROTO_IP, IPPROTO_IPV6, IPPROTO_TCP, ... TCP_CORK, TCP_KEEPALIVE,

socket

socket SOCKET,DOMAIN,TYPE,PROTOCOL Opens a socket of the specified kind and attaches it to filehandle SOCKET. DOMAIN, TYPE, and PROTOCOL are specified the same as for the syscall of the same name. You should use Socket first to get the proper definitions imported. See the examples in Sockets: Client/Server Communication in perlipc. On systems that support a close-on-exec flag on files, the flag will be set for the newly opened file descriptor, as determined by the value of $^F. See $^F in perlv

Smartmatch Operator

Smartmatch Operator First available in Perl 5.10.1 (the 5.10.0 version behaved differently), binary ~~ does a "smartmatch" between its arguments. This is mostly used implicitly in the when construct described in perlsyn, although not all when clauses call the smartmatch operator. Unique among all of Perl's operators, the smartmatch operator can recurse. The smartmatch operator is experimental and its behavior is subject to change. It is also unique in that all other Perl operators impose a cont

sleep

sleep EXPR sleep Causes the script to sleep for (integer) EXPR seconds, or forever if no argument is given. Returns the integer number of seconds actually slept. May be interrupted if the process receives a signal such as SIGALRM . eval { local $SIG{ALARM} = sub { die "Alarm!\n" }; sleep; }; die $@ unless $@ eq "Alarm!\n"; You probably cannot mix alarm and sleep calls, because sleep is often implemented using alarm. On some older systems, it may sleep up to a full second less than what