#!/usr/bin/perl -w use strict; use diagnostics; my %hash = ( VERTRAG1 => '123', VERTRAG2 => '345', VERTRAG3 => '678', VERTRAG4 => '91011', FOO => '91011', BAR => '91011', ); foreach my $temp (sort {substr ($b,7) <=> substr ($a,7)} grep {/^VERTRAG(\d+)$/ && $1 < 3} keys %hash) { print "Untersuche $temp\n"; }