1. Home
  2. Computing & Technology
  3. Perl

Perl array join() function - Quick Tutorial
How to use the array join() function

From About.com

$STRING = join(JOINER, @LIST);
Perl's join() function is used to connect all the elements of a specific list or array into a single string with the JOINER expression. The list is concatenated into one string with the element contained in the JOINER variable in between each item.
@myNames = ('Jacob', 'Michael', 'Joshua', 'Matthew');
$someNames = join(', ', @myNames);
Think of the @myNames array as a row of numbered boxes, each with a name in it. The join() function would take all of the content in those boxes in the @myNames array and connect them together with a comma and a space. The value of @someNames then becomes "Jacob, Michael, Joshua, Matthew". The list of names is concatenated, or joined, by commas.
More Perl Quick Tips
Explore Perl
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Perl
  4. Programming Perl
  5. Perl join function reference - learn how to use Perl's join() function in this quick tutorial.

©2009 About.com, a part of The New York Times Company.

All rights reserved.