To append a string to another string in Perl, you can use the .
operator or the .=
operator.
In this example,
$str1
with a value of "Hello"
..
operator to append the string " World"
to $str1
..
operator concatenates the two strings and returns the result.my $str1 = "Hello";
$str1 = $str1 . " World";
print $str1;
Hello World
In this example,
$str2
with a value of "banana"
..=
operator to append the string "apple"
to $str2
..=
operator concatenates the two strings and modifies the original $str2
.my $str2 = "banana";
$str2 .= "apple";
print $str2;
bananaapple
In this tutorial, we learned How to Append a String to another String in Perl language with well detailed examples.