## 7.1. The Basics

KildClient has a built-in Perl interpreter. To run a perl statement, just type if preceded by a slash (`/`) in the command entry box. The statement will be executed by the Perl interpreter instead of being sent to the MUD.

The statement can be anything that Perl will accept. You can actually execute several Perl statements if you separate them with `;` (no need to add `/` again, just once in the beginning of the line). You can call sub-routines, execute conditional or loop constructions, call a built-in function, do variable assignments, or even define a sub-routine. However, the statement must be complete. You cannot enter something like `/$myVar =` and then enter `/"some_value";`, the statement must be complete in one line. Technically, each line you enter is executed inside an `eval` block, so anything you want executed must be valid code inside an `eval` block.

To send a line that starts with a `/` to the MUD, use two slases: typing `//info` sends `/info` to the MUD.

All built-in Perl functions are accessible for you to use, and you can load Perl modules and use their functionality. However, that is not enough, because Perl's built-in functions will not allow you to interact with the World. Because of that, KildClient defines a set of functions that you can use to interact with the World. A full list describing them detailedly is found in Appendix A, Global Function Reference, but some of the most useful ones will be described in this Chapter. Many of these functions deal with creating and editing triggers, gags, aliases etc. These will be described in the corresponding chapters.

It is possible to get help on all functions using the `help` function. It takes as argument the name of the function. Note that since `help` is nothing else than another Perl function, the name of the function for which you want help is just an argument to it, and must be passed as a string. That is, to get help on the `echo` function, type `/help "echo"`. (Naturally, you can enclose `"echo"` in parenthesis, but this is not necessary.)

Some functions are in a way global, that is, they do not refer to a specific world. One such example is `colorize` (see `colorize`), which inserts ANSI color codes in strings (useful when you want to print something in the screen). These are called like any built-in Perl function. For example, if you enter `/$colorstr = colorize("&WI'm in white!")`, the variable `$colorstr` will hold a string that would be printed in white.

Many functions, however, are specific to a World, such as `echo` (see `$world->echo`), which prints something in the World window (but does not send it to the World). Because of that, they are called in a slightly different way. To print that string which has just been created, you would enter `/$world->echo($colorstr)`. Those that know Perl will recognized this as a method call of the `$world` instance. Indeed, `$world` is an instance of the class `World` class. This class defines several functions that allow interaction with a World. On start-up, the `$world` variable is created and references the current World.

It is also possible to control other worlds, if you have a variable pointing at them. You can get such a variable with the `getworld` function (see `getworld`). In that case, you should use the variable you got instead of `$world`.

If all the above did not make sense to you, do not worry. Just remember that many functions have to be called by adding `$world->` to the front. These functions will always be listed with that in front.

When a World is opened, the Perl interpreter reads and executes a file you specify. (See Section 4.5.1, “Scripting” for information on how to specify the file.) In this file, you can define sub-routines and variables. They will be then available for you to use during your session. If you define a sub-routine called `sendGreetings`, you can type `/sendGreetings` and the sub-routine will be executed. Or, if you define a variable, you can use it anywhere.

It should be noted that each World has its own Perl interpreter, with its functions and variables. What you do in one World does not affect the others.