Perl join Function
This function combines the elements of LIST into a single string using the value of EXPR to separate each element. It is effectively the opposite of split.
Note that EXPR is only interpolated between pairs of elements in LIST; it will not be placed either before the first or after the last element in the string. To join together strings without a separator, supply an empty string rather than undef.
Following is the simple syntax for this function −
join EXPR, LIST
This function returns the joined string.
Following is the example code showing its basic usage −Live Demo
#!/usr/bin/perl $string = join( "-", "one", "two", "three" ); print"Joined String is $string\n"; $string = join( "", "one", "two", "three" ); print"Joined String is $string\n";
When above code is executed, it produces the following result −
Joined String is one-two-three Joined String is onetwothree