How to apply splice or any other function to several different arrays in Perl?

arrays, loops, perl

Solution

You could iterate over an array of references:

@all_arrays = \( # Note the ref-making backslash applied to the list
    @identifiers,
    @sequences,
    @optional_informations,
    @quality_scores,
    @barcodes
);
for $array (@all_arrays)
{
    splice @$array, $i, 1;
}

Problem

I'm trying to shorten the following code: ``` if ( /MATCH/ ){ splice @identifiers, $i, 1; splice @sequences, $i, 1; splice @optional_informations, $i, 1; splice @quality_scores, $i, 1; splice @barcodes, $i, 1; } ``` Is there a way to iterate over each array and perform splice or any other function?

Original source