1. Perl
  2. here

Perl builtin functions

A list of Perl builtin functions. Builtin functions are functions that Perl provides from the beginning. Explains how to call a function, pass arguments, and receive a return value. Please use it as a reference.

String

A function used to process strings.

join Concatenate strings by specifying a delimiter
length Get the length of a string
substr Cut and replace strings
index Character search
rindex Search for characters (from the end)
split Split a string by specifying a delimiter
reverse Reverse the strings
uc Convert to uppercase
ucfirst Convert first letter to uppercase
lc Convert to lowercase
lcfirst Convert first letter to lowercase
sprintf Format string
chomp Remove a line break
chr Convert numbers to ASCII characters
ord Convert ASCII characters to numbers
oct Octal conversion
hex Hexadecimal conversion
crypt Create a digest and check your password

Regular expression

Functions related to regular expression.

quotemeta Regular expression escape

Array manipulation

A function for manipulating arrays.

shift Extract the beginning of an array element
unshift Add element to the beginning of the array
pop Extract the last element of the array
push Add elements to the end of the array
splice Detailed manipulation of array elements
grep Extract elements that match the conditions
map Map values
sort sort
reverse Reverse the order of the array

Hash operation

A function for manipulating hashes.

keys Get a list of hash keys
values Get a list of hash values
each Fetch the hash key and value in order
exists Confirmation of the existence of the hash key
delete Delete hash key and value
reverse Swap the hash key and value

Subroutine

Functions related to subroutine.

wantarray Judgment of context
caller Caller information
return Returns a return value

File input/output

Function used for file input/output.

print String output
printf Formatted string output
open File open
close File close
sysopen Low level file open
getc Get one character
binmode Open mode change
flock File lock
opendir Directory open
closeddir Directory closed
readdir Read directory
read Read from a file by specifying the number of bytes
sysread Read from a file with a specified number of bytes (no buffering)
syswrite Write to file by specifying the number of bytes (no buffering)

Value definition

A function related to the definition of a value.

undef Get and set undefined values
defined Check if the value is defined

Context

scalar function Evaluate in scalar context

File operation

Create/delete files/directories and other functions.

unlink Delete file
chdir Change current directory
mkdir Creating a directory
rmdir Delete directory
chmod Change permissions
stat Get file information
fileno Get file descriptor
glob Get a list of files
umask Mask settings
__LINE__ Get line number
__FILE__ Get file name
__DATA__ Data section

Date/Time

A function that manipulates date/time.

time Current time
localtime Current time(with locale)
sleep Sleep for a specified time

Mathematical functions

Mathematical function.

abs Absolute value
sqrt square root
int Get the integer part
ceil Round up the decimal point
floor Decimal point devaluation
rand Random value
looks_like_number Numerical judgment
pi pie
deg2rad Angle conversion
sin Ask for a sign
cos Ask for cosine
exp Exponential
log Log function
srand Reproducible random numbers

See the following articles for the basics of handling numbers in Perl.

Object Oriented

Functions related to object-oriented.

bless Object creation
__PACKAGE__ Get the package name

Exception handling

Function used in Exception handling.

die Exit the program
warn Output warning
eval Catch the exception

Interprocess communication

Function used in interprocess communication.

system Run another process
fork Fork
wait Wait for child process
getpwuid Get user ID
getpwnam Get username
getgrnam Get group name
kill Kill the process

Read configuration file

do Read the configuration file

Binary processing

pack Pack the data in binary format
unpack Restore packed data

FAQ

Where are the syntaxes such as if, for, and foreach explained?

For syntax such as if, for, and foreach, see the article on the syntax list.

How do I create my own function?

If you want to create the function yourself, see the following article. We use a function called a subroutine.

Related Informatrion