Built in functions

A function receives an argument or a list of arguments, sometimes performs a set of commands, and returns a value.

Examples of built in functions:

length

The length function receives a scalar variable / value and returns its length in bytes.

Given a string, length will return its number of characters.

Examples:

  $result = length ($some_string);
  _______   ______  ____________
 
#  return  function   argument
#  value
 
 
  $result = length ("university"); #$result gets 10

In the length function, the value of the argument remains unchanged.

chop

The chop function changes its argument (a string variable) so that its last character is removed. The function returns the removed character.

Example.

print

The print command is actually a function. It receives a string or a comma-separated list of strings as argument(s) and prints it. The print function return 1 if successful, 0 otherwise.

As in all built in functions, the parentheses surrounding the argument(s) are optional, and indeed when using print we often omit them.

Example.


Table of Contents