my %hash = ('prefix_1' => 1, 'test_2' => 2); my @keys; foreach (keys %hash){ push(@keys, $_) if /^prefix_/; } print "Ergebnis: @keys";