Leser: 1
|< 1 2 >| | 15 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
use strict;
use warnings;
use Data::Dumper;
my %hash;
print "key foo->bar exists\n"
if exists $hash{foo}{bar};
print Dumper(\%hash);
1
2
3
4
my %hash;
print "key foo->bar exists\n"
if(exists($hash{foo}) and exists($hash{foo}{bar}));
1
2
3
4
5
6
7
8
9
10
11
use strict;
use warnings;
use Data::Dumper;
my %hash;
my $tmp;
print "key foo->bar exists\n"
if $tmp = $hash{foo} and exists $tmp->{bar};
print Dumper(\%hash);
1
2
3
4
5
6
7
8
9
10
11
use strict;
use warnings;
use Data::Dumper;
my %hash;
my $tmp;
print "key foo->bar exists\n"
if $tmp = $hash{foo} and exists $tmp->{bar};
print Dumper(\%hash);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use Benchmark;
my @keys = qw(a b c d e f g h i j);
sub _exists {
my %keys;
exists $keys{$_}{1}
for @keys;
}
sub _keyref {
my %keys;
$keys{$_} = {}
for @keys;
}
Benchmark::cmpthese(-1, {
'exists' => \&_exists,
'key=ref' => \&_keyref,
});
|< 1 2 >| | 15 Einträge, 2 Seiten |