I am working on a perl module and looking for an output (string) of the form : a:value1 OR a:value2 OR a:value3 OR ...
The values value1, value2, value3... are in an array (say, @values).
I know we could use join( ' OR ', @values ) to create a concatenated string of the form: value1 OR value2 OR value3 OR ...
But as you see above, I need an additional a: to be prepended to each value.
What would be a neat way to do so?
You typically use map for these kinds of things:
Output:
mapis a simple looping construct, which is useful when you want to do apply some simple logic to every element of a list without making too much clutter of your code.