I have an array of strings: @array
I want to concatenate all strings beginning with array index $i
to $j
.
How can I do this?
The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.
Perl Array join() FunctionThe Perl programming language join() function is used to connect all the elements of a specific list or array into a single string using a specified joining expression. The list is concatenated into one string with the specified joining element contained between each item.
Perl strings are concatenated with a Dot(.) symbol. The Dot(.) sign is used instead of (+) sign in Perl.
Use the array push() function to add an element to an array.
$newstring = join('', @array[$i..$j])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With