Perl has two operators related to String scalar types.

  • Concatenation, Symbol is .
  • String Repetition Operator, Symbol is x

These operators help developers to manipulate and process the string data.

$str1 = "one";
$str2 = "two";

$result = $str1." ".$str2;
print "$result";

String Repetition Operator

lowercase x, a;sp called Repetition that repeats the given string n times

Syntax

strVariable x n

It contains left and right operands for an operator. left is repeated by the right side value.

striVariable value is repeated n times.

$str1 = "one";
$result = $str1 x 3;
print "$result";

Output:

oneoneone

Other String operators

What are the string operators in Perl?

String operators are used to manipulate string scalar values in Perl. It contains two operators in Perl

  • Concatenate (.), which concatenates one string to the end of another string.
  • repetition (x), that repeats the string multiple times.