|< 1 2 >| | 12 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
my %hash = (foo => {});
my $ref = \%hash;
for (0..100000) {
print $_, " ";
$ref = $ref->{foo};
$ref->{foo} = {};
}
1
2
3
4
5
6
7
8
my %hash = (foo => {});
my $ref = \%hash;
for (0..100000) {
print $_, " ";
$ref = $ref->{foo};
$ref->{foo} = {};
}
89232 Segmentation fault
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/bin/perl use strict; use warnings; my %hash = (foo => {}); my $ref = \%hash; for (0..100000) { print $_, "\n"; $ref = $ref->{foo}; $ref->{foo} = {}; } #%hash = {}; # <= Speicherzugriffsfehler my $delete; $delete=sub { my $href=shift(@_); $delete->($href->{foo}) if(ref($href->{foo}) eq 'HASH'); %$href=(); }; $delete->(\%hash); print "ende\n";
|< 1 2 >| | 12 Einträge, 2 Seiten |