Perl join() Function

What is join() Function in Perl programming?


The join() function joins a list into a string using a separator.


join SEP,LIST;

In the above syntax, join() function takes a "seperator", a "list" as arguments.

Example :

#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
@color = ('Green','Orange','Blue','Pink','Peach','Black');
$col1 = join("+", @color);
print("The strings joined using '+': $col1,n");
print "<br>";
$col2 = join("-", @color);
print("The strings joined using '-': $col2,n");
Result :

The strings joined using '+': Green+Orange+Blue+Pink+Peach+Black,
The strings joined using '-': Green-Orange-Blue-Pink-Peach-Black,

In the above example first the elements are joined using a "+", then using a "-".

Ask Questions

Ask Question