Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Built-in Functions (P5 Runtime)

pperl P5 runtime built-in functions — faithful perl5 C mirror in Rust.

Array Functions

  • delete — delete($h{key}).
  • each — each(%hash).
  • exists — exists($h{key}).
  • keys — keys(%hash).
  • pop — pop(@array).
  • push — push(@array, @list).
  • shift — shift(@array).
  • sort — sort(@list).
  • splice — splice(@array, offset, length, list).
  • unshift — unshift(@array, @list).
  • values — values(%hash).

File Functions

Formatting

  • sprintf — sprintf($fmt, @args) builtin.

Hash Functions

I/O Functions

  • binmode — set binary/layer mode on a filehandle.
  • close — close a file handle.
  • eof — check end-of-file.
  • fileno — fileno(FH)
  • getc — getc(FH)
  • open — open a file handle.
  • pipe — pipe(READ, WRITE)
  • print — print LIST (optionally to a filehandle).
  • printf — printf FORMAT, LIST.
  • readline — read line(s) from a filehandle.
  • say — say LIST (print with trailing newline).
  • seek — seek(FH, POS, WHENCE)
  • select — 1-arg: set default output FH
  • sysopen — sysopen(FH, PATH, FLAGS [, MODE]).
  • sysread — sysread(FH, SCALAR, LENGTH [, OFFSET]).
  • syswrite — syswrite(FH, SCALAR [, LENGTH [, OFFSET]]).
  • tell — tell(FH)
  • truncate — truncate(FH_OR_NAME, LENGTH).

Numeric Functions

  • abs — Returns the absolute value of its argument.
  • atan2 — Returns the arctangent of Y/X in the range -pi to pi.
  • cos — Returns the cosine of its argument (in radians).
  • exp — Returns e (Euler’s number) raised to the power of its argument.
  • int — Truncates a numeric value toward zero.
  • log — Returns the natural logarithm (base e) of its argument.
  • rand — Returns a pseudo-random floating-point number.
  • sin — Returns the sine of its argument (in radians).
  • sqrt — Returns the square root of its argument.
  • srand — Seeds the pseudo-random number generator used by rand.

Process Functions

  • alarm — alarm($seconds).
  • die — die(@args).
  • exec — exec(COMMAND)
  • exit — exit($status).
  • fork — fork()
  • kill — kill($sig, @pids)
  • sleep — sleep($seconds)
  • system — system(COMMAND) or system(PROG, ARGS…).
  • wait — wait()
  • waitpid — waitpid($pid, $flags)
  • warn — warn(@args).

Regular Expressions

  • m// — m// and m//g matching.
  • pos — pos($str)
  • qr — compile regex to blessed Regexp reference.
  • quotemeta — quotemeta($str).
  • s/// — s/// substitution.
  • split — split($pattern, $string, $limit).
  • tr — tr/// transliteration.

Scope and Variables

  • bless — bless($ref, $classname).
  • caller — caller() function.
  • defined — defined($x).
  • do — do ‘file.pl’.
  • pos — pos($str)
  • prototype — CORE::prototype(&sub) or prototype(“name”).
  • ref — ref($x), returns type name or empty string.
  • require — require ‘file.pl’ or require Module.
  • reset — reset() builtin.
  • tie — tie a variable to a class.
  • tied — return tied object for a variable.
  • undef — produce undef (or undefine a variable).
  • untie — unbind a tied variable.
  • vec — vec(STRING, OFFSET, BITS).
  • wantarray — wantarray().

String Functions

  • chomp — remove trailing newline, returns number of chars removed.
  • chop — remove last character, returns removed character.
  • chr — chr($n), convert integer to single-byte character.
  • crypt — crypt($plaintext, $salt)
  • hex — hex($str).
  • index — find substring position.
  • join — join($sep, @list).
  • lc — lowercase (lc($x)).
  • lcfirst — lowercase first character (lcfirst($x)).
  • length — string length.
  • oct — oct($str).
  • ord — ord($s), get numeric value of first character.
  • pack — pack(TEMPLATE, LIST).
  • quotemeta — quotemeta($str).
  • reverse — reverse(@list) in list context, reverse($str) in scalar context.
  • rindex — reverse find substring position.
  • sprintf — sprintf($fmt, @args) builtin.
  • substr — substring extraction.
  • uc — uppercase (uc($x)).
  • ucfirst — uppercase first character (ucfirst($x)).
  • unpack — unpack(TEMPLATE, EXPR).

Time Functions