|< 1 2 >| | 12 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
my %source;
my %dest;
my @buffer;
$source{key1} = "value1";
$source{key2} = "value2";
push (@buffer, %source);
$source{key1} = "value3";
$source{key2} = "value4";
push (@buffer, %source);
#(...)
%source = pop(@buffer);
print $source{key1};
Odd number of elements in hash assignment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %source;
my %dest;
my @buffer;
$source{key1} = "value1";
$source{key2} = "value2";
push( @buffer, %source );
$source{key1} = "value3";
$source{key2} = "value4";
push( @buffer, %source );
#(...)
print Dumper \@buffer;
%dest = splice @buffer, 0, 2;
print Dumper \%dest;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my ( @buffer, %source, %dest )
$source{key1} = "value1";
$source{key2} = "value2";
push (@buffer, \%source); # beachte den "\"
$source{key1} = "value3";
$source{key2} = "value4";
push (@buffer, \%source); # beachte den "\"
#(...)
%source = %{ pop(@buffer) }; # und hier das %{ }
print $source{key1};
push @buffer, { %source };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
my ( @buffer, %source, %dest )
$source{key1} = "value1";
$source{key2} = "value2";
push (@buffer, { %source } ); # beachte die { ... }
$source{key1} = "value3";
$source{key2} = "value4";
push (@buffer, { %source } ); # beachte die { ... }
#(...)
%source = %{ pop(@buffer) }; # und hier das %{ }
print $source{key1};
|< 1 2 >| | 12 Einträge, 2 Seiten |