forked from szabgab/perlmaven.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin.tt
46 lines (33 loc) · 1.06 KB
/
join.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
=title join
=timestamp 2013-02-04T12:45:56
=indexes join
=status show
=books beginner_book
=author szabgab
=index 1
=archive 1
=feed 1
=comments 1
=social 1
=abstract start
I guess there is not much to say about the <hl>join</hl> function except that
it is the counter part of the <hl>split</hl> function.
=abstract end
This function can take several elements of a list or an array and join them together into a string.
<code lang="perl">
use strict;
use warnings;
use v5.10;
my @names = ('Foo', 'Bar', 'Moo');
my $str = join ':', @names;
say $str; # Foo:Bar:Moo
my $data = join "-", $str, "names";
say $data; # Foo:Bar:Moo-names
$str = join '', @names, 'Baz';
say $str; # FooBarMooBaz
</code>
The first paramter of the <b>join</b> function is the "connector",
the string that will be connecting all the other parameters.
The rest of the parameters of join will be flattened to a
list and the elements will be glued together with the given "connector".
This "connector" can be any string, even the empty string.