How to concatenate two or more strings in Perl using the period
Overview
Strings in Perl can be concatenated using the period ., which is an operator we can use to combine two or more strings.
Syntax
string1.string2.string3.stringN
The syntax for concatenating two or more strings in Perl
Parameters
string1, string2, string3,...,stringN: These are strings we want to join/concatenate.
Return value
A new string is returned which is a combination of all the strings concatenated.
Example
# create some strings$a = "Welcome";$b = " to";$c = "Nice to have you here!";# concatenate all strings$d = $a.$b." Edpresso! ".$c;# print the concatenated stringprint $d;we
Explanation
- Lines 2-4: We create some strings.
- Line 7: We concatenate the strings using the period operator
.. - Line 10: We print the concatenated string to the console.