FUNCIONES Y PALABRAS RESERVADAS PERL
perlfunc - Perl builtin functions
The functions in this section can serve as terms in an expression. They fall into two major categories: list operators and named unary operators. These differ in their precedence relationship with a following comma. (See the precedence table in perlop.) List operators take more than one argument, while unary operators can never take more than one argument. Thus, a comma terminates the argument of a unary operator, but merely separates the arguments of a list operator. A unary operator generally provides a scalar context to its argument, while a list operator may provide either scalar or list contexts for its arguments. If it does both, the scalar arguments will be first, and the list argument will follow. (Note that there can ever be only one such list argument.) For instance, splice() has three scalar arguments followed by a list, whereas gethostbyname() has four scalar arguments.
In the syntax descriptions that follow, list operators that expect a list (and provide list context for the elements of the list) are shown with LIST as an argument. Such a list may consist of any combination of scalar arguments or list values; the list values will be included in the list as if each individual element were interpolated at that point in the list, forming a longer single-dimensional list value. Elements of the LIST should be separated by commas.
Any function in the list below may be used either with or without parentheses around its arguments. (The syntax descriptions omit the parentheses.) If you use the parentheses, the simple (but occasionally surprising) rule is this: It looks like a function, therefore it is a function, and precedence doesn't matter. Otherwise it's a list operator or unary operator, and precedence does matter. And whitespace between the function and left parenthesis doesn't count–so you need to be careful sometimes:
print 1+2+4; # Prints 7.
print(1+2) + 4; # Prints 3.
print (1+2)+4; # Also prints 3!
print +(1+2)+4; # Prints 7.
print ((1+2)+4); # Prints 7.
If you run Perl with the -w switch it can warn you about this. For example, the third line above produces:
print (…) interpreted as function at - line 1.
Useless use of integer addition in void context at - line 1.
A few functions take no arguments at all, and therefore work as neither unary nor list operators. These include such functions as time and endpwent. For example, time+86_400 always means time() + 86_400.
For functions that can be used in either a scalar or list context, nonabortive failure is generally indicated in a scalar context by returning the undefined value, and in a list context by returning the null list.
Remember the following important rule: There is no rule that relates the behavior of an expression in list context to its behavior in scalar context, or vice versa. It might do two totally different things. Each operator and function decides which sort of value it would be most appropriate to return in scalar context. Some operators return the length of the list that would have been returned in list context. Some operators return the first value in the list. Some operators return the last value in the list. Some operators return a count of successful operations. In general, they do what you want, unless you want consistency.
An named array in scalar context is quite different from what would at first glance appear to be a list in scalar context. You can't get a list like (1,2,3) into being in scalar context, because the compiler knows the context at compile time. It would generate the scalar comma operator there, not the list construction version of the comma. That means it was never a list to start with.
In general, functions in Perl that serve as wrappers for system calls of the same name (like chown(2), fork(2), closedir(2), etc.) all return true when they succeed and undef otherwise, as is usually mentioned in the descriptions below. This is different from the C interfaces, which return -1 on failure. Exceptions to this rule are wait, waitpid, and syscall. System calls also set the special $! variable on failure. Other functions do not, except accidentally.
Perl Functions by Category
Here are Perl's functions (including things that look like functions, like some keywords and named operators) arranged by category. Some functions appear in more than one place.
Functions for SCALARs or strings
chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct, ord, pack, q/STRING/, qq/STRING/, reverse, rindex, sprintf, substr, tr/, uc, ucfirst, y/
Regular expressions and pattern matching
m, pos, quotemeta, s/, split, study, qrNumeric functionsabs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srandFunctions for real @ARRAYspop, push, shift, splice, unshiftFunctions for list datagrep, join, map, qw/STRING/, reverse, sort, unpackFunctions for real %HASHesdelete, each, exists, keys, valuesInput and output functionsbinmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock, format, getc, print, printf, read, readdir, rewinddir, seek, seekdir, select, syscall, sysread, sysseek, syswrite, tell, telldir, truncate, warn, writeFunctions for fixed length data or recordspack, read, syscall, sysread, syswrite, unpack, vecFunctions for filehandles, files, or directories-X, chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat, mkdir, open, opendir, readlink, rename, rmdir, stat, symlink, umask, unlink, utimeKeywords related to the control flow of your perl programcaller, continue, die, do, dump, eval, exit, goto, last, next, redo, return, sub, wantarrayKeywords related to scopingcaller, import, local, my, package, useMiscellaneous functionsdefined, dump, eval, formline, local, my, reset, scalar, undef, wantarrayFunctions for processes and process groupsalarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe, qx/STRING/, setpgrp, setpriority, sleep, system, times, wait, waitpidKeywords related to perl modulesdo, import, no, package, require, useKeywords related to classes and object-orientednessbless, dbmclose, dbmopen, package, ref, tie, tied, untie, useLow-level socket functionsaccept, bind, connect, getpeername, getsockname, getsockopt, listen, recv, send, setsockopt, shutdown, socket, socketpairSystem V interprocess communication functionsmsgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget, shmread, shmwriteFetching user and group infoendgrent, endhostent, endnetent, endpwent, getgrent, getgrgid, getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwentFetching network infoendprotoent, endservent, gethostbyaddr, gethostbyname, gethostent, getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber, getprotoent, getservbyname, getservbyport, getservent, sethostent, setnetent, setprotoent, setserventTime-related functionsgmtime, localtime, time, timesFunctions new in perl5abs, bless, chomp, chr, exists, formline, glob, import, lc, lcfirst, map, my, no, prototype, qx, qw, readline, readpipe, ref, sub*, sysopen, tie, tied, uc, ucfirst, untie, use* - sub was a keyword in perl4, but in perl5 it is an operator, which can be used in expressions.Functions obsoleted in perl5dbmclose, dbmopenPortabilityPerl was born in Unix and can therefore access all common Unix system calls. In non-Unix environments, the functionality of some Unix system calls may not be available, or details of the available functionality may differ slightly. The Perl functions affected by this are:-X, binmode, chmod, chown, chroot, crypt, dbmclose, dbmopen, dump, endgrent, endhostent, endnetent, endprotoent, endpwent, endservent, exec, fcntl, flock, fork, getgrent, getgrgid, gethostent, getlogin, getnetbyaddr, getnetbyname, getnetent, getppid, getprgp, getpriority, getprotobynumber, getprotoent, getpwent, getpwnam, getpwuid, getservbyport, getservent, getsockopt, glob, ioctl, kill, link, lstat, msgctl, msgget, msgrcv, msgsnd, open, pipe, readlink, rename, select, semctl, semget, semop, setgrent, sethostent, setnetent, setpgrp, setpriority, setprotoent, setpwent, setservent, setsockopt, shmctl, shmget, shmread, shmwrite, socket, socketpair, stat, symlink, syscall, sysopen, system, times, truncate, umask, unlink, utime, wait, waitpidFor more information about the portability of these functions, see perlport and other available platform-specific documentation.Alphabetical Listing of Perl Functions-Xabs, accept, alarm, atan2bind, binmode, blesscaller, chdir, chmod, chomp, chop, chown, chr, chroot, close, closedir, connect, continue, cos, cryptdbmclose, dbmopen, defined, delete, die, do, dumpeach, endgrent, endhostent, endnetent, endprotoent, endpwent, endservent, eof, eval, exec, exists, exit, expfcntl, fileno, flock, fork, format, formlinegetc, getgrent, getgrgid, getgrnam, gethostbyaddr, gethostbyname, gethostent, getlogin, getnetbyaddr, getnetbyname, getnetent, getpeername, getpgrp, getppid, getpriority, getprotobyname, getprotobynumber, getprotoent, getpwent, getpwnam, getpwuid, getservbyname, getservbyport, getservent, getsockname, getsockopt, glob, gmtime, goto, grepheximport, index, int, ioctljoinkeys, killlast, lc, lcfirst, length, link, listen, local, localtime, lock, log, lstatm, map, mkdir, msgctl, msgget, msgrcv, msgsnd, mynext, nooct, open, opendir, ord, ourpack, package, pipe, pop, pos, print, printf, prototype, pushq, qq, qr, quotemeta, qw, qxrand, read, readdir, readline, readlink, readpipe, recv, redo, ref, rename, require, reset, return, reverse, rewinddir, rindex, rmdirs, scalar, seek, seekdir, select, semctl, semget, semop, send, setgrent, sethostent, setnetent, setpgrp, setpriority, setprotoent, setpwent, setservent, setsockopt, shift, shmctl, shmget, shmread, shmwrite, shutdown, sin, sleep, socket, socketpair, sort, splice, split, sprintf, sqrt, srand, stat, study, sub, substr, symlink, syscall, sysopen, sysread, sysseek, system, syswritetell, telldir, tie, tied, time, times, tr, truncateuc, ucfirst, umask, undef, unlink, unpack, unshift, untie, use, utimevalues, vecwait, waitpid, wantarray, warn, writey Viajes y turismo
PALABRAS RESERVADAS PERL
The functions in this section can serve as terms in an expression. They fall into two major categories: list operators and named unary operators. These differ
El contenido original se encuentra en https://programacionfacil.com/perl/palabras_reservadas/
Todos los derechos reservados para el autor del contenido original (en el enlace de la linea superior)
Si crees que alguno de los contenidos (texto, imagenes o multimedia) en esta página infringe tus derechos relativos a propiedad intelectual, marcas registradas o cualquier otro de tus derechos, por favor ponte en contacto con nosotros en el mail [email protected] y retiraremos este contenido inmediatamente