I have an array of strings say whose length can be anywhere from 1 to 20. I need to join the 1st 3 elements of array into a string. I used.
@a = ("Hello","world","welcome");
$b = join(":",@a[0..2])
This produces desired output Hello:World:welcome
But When the length of the array is less than 3 say @a = ("hello","wolrd")
I get Hello:world: as output. If I have 1 variable I get Hello:: as the output.
I want to restrict joining based on the array's length. Is there any way out to do this?