while(){ if (/(\%.*?) /){ $item = $1; $item =~ s/\%//; push @dynamicterms, $item } }