for my $i (0.. $#excerpts){ if (excerpts[$i] =~ /$re2/({ $%{$excerpts[$i]}{fpart} = $1; $%{$excerpts[$i]}{bpart} = $3; } }