Scalar Data

Operators for strings

We will mention the most common one:



$a = "wiki" . "pedia";    # $a is now "wikipedia"
Do not forget to add spaces when you concatenate separate words:
$b = "hello" . " world";     # $b is now "hello world"
It is also possible to concatenate variable names, as in these examples:
$c = $a . $b;

$d = $b . " what a day";
Sometimes you can get the same result with either concatenation (a) or variable interpolation (b):
$sentence1 = $protein . " contains " . $no . " amino acids";

$sentence2 = "$protein contains $no amino acids";

Table of Contents.
Previous | Next.