Hi,
I'm trying to find a simple way to print an array with a comma separating each element.
But a need a way to apply "styles" specific to each element; <span class="{style}"> before, and </span> after each element.
Is it possible to use the "print join" and still be able to apply specific "styles" to each element ?
I could always loop around each elements, but I wanted to know if there's a simple way to do this.
Array
Expected results
This won't work if I want to apply something to each element
I'm trying to find a simple way to print an array with a comma separating each element.
But a need a way to apply "styles" specific to each element; <span class="{style}"> before, and </span> after each element.
Is it possible to use the "print join" and still be able to apply specific "styles" to each element ?
I could always loop around each elements, but I wanted to know if there's a simple way to do this.
Array
Code:
@array = ("Red","Blue","Green","Purple");
Expected results
Code:
<span class="Red">Red</span>, <span class="Blue">Blue</span>, <span class="Green">Green</span>, <span class="Purple">Purple</span>
This won't work if I want to apply something to each element
Code:
print join(', ', @array), "\n";