I have columns in @columns
:
my @columns =('column1', 'column2', 'column3');
and I have separators in @separators
:
my @separators = (',', '|');
I want to insert the separators between columns, one by one:
column1,column2|column
my solution is:
(@columns »~» (|@separators,"")).join("")
Here I have three columns and two separators, and how about insert N-1
separators between N
columns?
Assuming that @separators
has the right number of values, you could use roundrobin
.
roundrobin( @columns, @separators ).flat.join()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With