use strict;
use warnings;

my $range = 45;
my @zahlen;
my $d = 0;
for (my $i = 1; $i<= 6; $i++) {
    my $z = int(rand($range))+1;    
    if (grep {$_ == $z} @zahlen) {
       $d++; 
       redo;
    }
    push (@zahlen, $z);
    print "$i $z\n";
}

print "mehrfach $d\n";