Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

perl
join
communitycreator

What is the join() method in Perl?

okwudili onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The join() method in Perl is used to join strings that are separated by the specified separator.

Syntax

join(separator, *strings)

Parameters

  • separator: A string or a character that separates the joined strings.

  • *strings: One or more strings that we want to join.

Return value

This method returns a new string with the strings joined together and separated by the separator separator.

Example

Let’s look at the code below:

# join strings
$str1 = join(":", "hello", "we");
$str2 = join("-", "Edpresso", "is", "awesome");
$str3 = join("**", "the", "stars");
# print results
print "$str1\n";
print "$str2\n";
print "$str3";
Joining strings and separating them with a separator

Explanation

  • Lines 2 to 4: We use the join() method to join some strings and the results are saved in some variables.
  • Lines 7 to 9: We print the results to the console.

RELATED TAGS

perl
join
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring