use CGI; my $q = new CGI; my %input = $q->Vars; foreach my $key (keys %input) { if ($key =~ m{\Aqty\d+}) { # DO SOMETHING } }