perl - Concatenating elements from two arrays of same indexes -
i facing issue while concatenating elements of indexes 2 arrays.
example:
@x=(1,2,3,4); @y=(5,6,7,8);
i want concatenate
$x[0]"_"$y[0]
like this:
if @i=(..n), $x[$i]"_"$y[$i]
suggest possible solution.
to repeat process n elements in array, can following
my @x=(1,2,3,4); @y=(5,6,7,8); @concatenated_array=(); $i (0 .. $n) # define $n <= min($#x,$#y) { push @concatenated_array, $x[$i] ."_". $y[$i]; } print "@concatenated_array\n";
Comments
Post a Comment