Leser: 1
|< 1 2 >| | 12 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
my %hash=(a=>1,b=>2,x=>1);
my %hsah;
while (my ($key, $val) = each %hash) {
$hsah{$val}++;
}
while (my ($key, $val) = each %hsah) {
next if $val == 1;
print "$val mal: $key\n";
}
1
2
3
4
5
6
7
8
9
sub test_hash {
my $hashref = shift;
my %hash;
foreach ( values %{$hashref} ) {
$hash{$_}++;
return 1 if $hash{$_} > 1;
}
return 0;
}
1
2
3
4
5
6
sub test_hash {
my $hr = shift;
my %h;
return 1 if ++$h{$_} > 1 for values %$hr;
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use strict;
use warnings;
my %Hash = ( a => 1,
b => 2,
c => 3,
);
my %HasH = ( a => 1,
b => 2,
c => 1,
);
print test_hash(\%Hash), "\n";
print test_hash(\%HasH), "\n";
sub test_hash {
my $hr = shift;
my %h;
for (values %$hr) {return 1 if ++$h{$_} > 1}
return 0;
}
++$h{$_} > 1 ? return 1 : print "" for values %$hr;
|< 1 2 >| | 12 Einträge, 2 Seiten |