in reply to Help with placing the matches of a regex into an Array

A sample of your data and verbatim reports on your messages (are you sure they're 'error' messages, rather than warnings?) would be a great help in finding a way to help you.

But, that said, this is a llama-level primer-version of an approach to your titled issue:

#!/usr/bin/perl use 5.014; my @matches; my @arr = qw/a1 ab2 aab3 ac4 dc5 bc6 da7 cb8 dbca9 aa0/; for $_( @arr ) { if ($_ =~ m/a/g) { say "\t regex matches $_"; push @matches, $_; } } for my $match( @matches) { say $match; }

Note that this pushes each capture to the array, rather than replacing the array repeatedly, thus preserving only the last. That's something which you might have spotted in the course of writing your question, had you provided the data.

For the reasoning behind this, see Re: a bit of monastery zen.

Update: One and all may consider this another illustration of the danger another Monk noted recently; the danger of keeping a tab open too long (long enough to answer a false alarm, in this case).