Join a list of strings into a single string.
The join function combines a list of strings into a single string, placing a separator between each element. The first argument is the separator string, and the remaining arguments form the list to join.
join is the inverse of split. While split breaks a string apart, join puts pieces back together. The separator can be any string, including an empty string to concatenate elements directly.
This function is commonly used for building output strings, constructing file paths, and reassembling data that was previously parsed with split.
| Name | Description | Optional |
|---|---|---|
SEPARATOR |
The string placed between each element in the result. | No |
LIST |
The list of strings to join together. | No |
my @words = ('Hello', 'World');
my $str = join ', ', @words;
print $str; # Hello, World