in reply to iterating over array to create smaller arrays based on pattern match

Sounds to me like what you want to do is sort all the entries into a hash of arrays (HoA), where the key is the prefix. Something like:

my %sorted; foreach my $item (@array) { my ($prefix) = $item =~ /^(\w+)/; push @{$sorted{$prefix}}, $item; }

Then you can work your way through the list of items for each prefix like this:

foreach my $prefix (keys %sorted) { my @items = @{$sorted{$prefix}}; # do something with @items... }

Does that make sense?

-sam