How to insert separators between columns?

  • A+

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:


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() 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: