my %hash; scalar(%hash) = 50_000; %hash = ('produkt1' => 1, .... 'produkt50000' => 50000); my @daten = (...); my @data_ids; $#data_ids = $#daten; foreach (@daten) { push (@data_ids, $hash{$_}); } # foreach