Leser: 21
1 2 3 4
my %test; $test {ebene1_anders} = 'test_erste_ebene'; $test{ebene1}{test1} = 'test 1, 2. Ebene'; $test{ebene1}{test2} = 'test 2, 2. Ebene';
$test2{ebene1} = delete $test{ebene1};
1 2 3 4 5
my $tmp = delete $hash{ebene1}; %hash2 = %$tmp; # oder gleich %hash2 = %{ delete $hash{ebene1} };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
DB<6> print Dumper \%test
$VAR1 = {
'ebene1' => {
'test1' => 'test 1, 2. Ebene',
'test2' => 'test 2, 2. Ebene'
},
'ebene1_anders' => 'test_erste_ebene'
};
DB<7> my $tmp = delete $test{ebene1};
DB<8> %test2 = %$tmp;
DB<9> print Dumper \%test
$VAR1 = {
'ebene1_anders' => 'test_erste_ebene'
};
DB<10> print Dumper \%test2
$VAR1 = {};
%test2 = %delete $test{ebene1};
%test2 = %{ delete $test{ebene1} };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
perl -w
my %test = (
'ebene1' => {
'test1' => 'test 1, 2. Ebene',
'test2' => 'test 2, 2. Ebene'
},
'ebene1_anders' => 'test_erste_ebene',
);
use Data::Dumper;
my $tmp = delete $test{ebene1};
my %test2 = %$tmp;
print Dumper \%test;
print Dumper \%test2;
__END__
$VAR1 = {
'ebene1_anders' => 'test_erste_ebene'
};
$VAR1 = {
'test1' => 'test 1, 2. Ebene',
'test2' => 'test 2, 2. Ebene'
};
Guest LanXoffwieso soll %test2 (resp "%hash2") vorher leer sein?
1 2 3 4
my $tmp = delete $test{ebene1}; %test2=( %test2, %$tmp ); # oder einzeilig %test2=( %test2, %{ delete $test{ebene1} } );
if (delete $test{ebene1_anders}) {}
if (delete $test{ebene1_anders}) {}
perl -E 'sub foo{$_=wantarray?"list":"scalar"}if(foo){say}'