2.7. String operators

Example 2-7. examples/scalars/string_operators.p6

#!/usr/bin/perl6

my $x = "Hello";
my $y = "World";

# ~ is the concatenation operator, ataching ons string after the other
my $z = $x ~ " " ~ $y;  #       the same as "$x $y"
say $z;                 # Hello World

my $w = "Take " ~ (2 + 3);     # you cannot write "Take (2 + 3)" here
say $w;                        # Take 5

$z ~= "! ";             #       the same as  $z = $z ~ "! ";
say "'$z'";             # 'Hello World '

# x is the string repetition operator
my $q = $z x 3;
print "'$q'\n";         # 'Hello World! Hello World! Hello World! '

~ concatenates two strings.

Example 2-8. examples/scalars/concat.p6

#!/usr/bin/perl6

print "First string:";
my $a = readline;
print "Second string:";
my $b = readline;

my $c = $a ~ $b;

say "\nResult: $c";