B
bhooshan.dixit
I have an array which looks something like this
Bob
Bruce
Tim
Jimmy
I want to add a comma ',' to the end of each element in the array
except for the last element.
Then I want to concatenate each element into a combined string and
store it in a single variable.
I figured out how to add the comma at the end basically by doing
something like this.
foreach(@list1)
{
s/(.*)/$1,/;
}
BUT i need some guidance on how to exclude the last comma on the last
element.
So basically my array show looks something like this.
Bob,
Bruce,
Tim,
Jimmy
notice how the comma is missing after Jimmy.
After the comma's are inserted I want to concatenate and put them in a
string
something like. $t="Bob,Bruce,Tim,Jimmy";
I am kinda a new to perl..so if someone can suggest me different
methods, It would be great.
Thanks
bcd
Bob
Bruce
Tim
Jimmy
I want to add a comma ',' to the end of each element in the array
except for the last element.
Then I want to concatenate each element into a combined string and
store it in a single variable.
I figured out how to add the comma at the end basically by doing
something like this.
foreach(@list1)
{
s/(.*)/$1,/;
}
BUT i need some guidance on how to exclude the last comma on the last
element.
So basically my array show looks something like this.
Bob,
Bruce,
Tim,
Jimmy
notice how the comma is missing after Jimmy.
After the comma's are inserted I want to concatenate and put them in a
string
something like. $t="Bob,Bruce,Tim,Jimmy";
I am kinda a new to perl..so if someone can suggest me different
methods, It would be great.
Thanks
bcd