my $input = 'foo+bar+baz';
my $i = 1;
my $string = join '&', map { 'keyword' . $i++ . '=' . $_ } split /\+/,
+ $input;
This might be the first time you see
map. It's not as hard as it looks:
map BLOCK LIST evaluates BLOCK for every item of the given LIST, aliassing
$_ to that item.
In other words:
map creates a list out of a list.
So this is what happens:
$input gets split, and the individual items are sent through
map, which prefixes "keyword#=", increasing the number by one. Then,
join joins them using supergl^W'&'. The result is put in
$string.
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$