I’m trying to join an array this way:
@cols = (1,2,3,4);
my $s = join("|$_", @cols);
print $s;
and I expect the following output:
1|2|3|4
but that doesn’t work.
I was also looking for some reduce-like function but I can’t find one nor I know how to write one in Perl.
Using CPAN is not an option as this program will be executed in computers I cannot install anything else.
What other similar function can I use for that purpose?
How can I write that generalized join or reduce function in Perl?
Thanks.
I suspect you want:
With reduce:
(though that produces a leading |).