Leser: 2
10 Einträge, 1 Seite |
my %hash=('key1' => 'val1', 'key2' => 'val2');
my %hash{'key1'}=('key1.1' => 'val1.1', 'key1.2' => 'val1.2');
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl -w
use strict;
my @chars = ("A".."Z");
my @nums = (0..9);
my %hash = (
nums => \@nums,
chars => \@chars
);
print $hash{'nums'}->[1];
my %hash=('key1' => 'val1', 'key2' => 'val2');
my $hash_ref=\%hash;
my $hash_ref={'key1' => 'val1', 'key2' => 'val2'}
my $hash2{'key_a'}=$hash_ref;
$hash2{'key_a'}={'key1' => 'val1', 'key2' => 'val2'};
1
2
3
4
5
%hash2=(
'key_a'=>{'key1' => 'val1', 'key2' => 'val2'},
'key_b'=>{'key3' => 'val3', 'key4' => 'val4'}
# ...
);
1
2
3
4
my %hash;
$hash{'key1'}={};
$hash{'key1'}{'key1.1'}='val1.1';
$hash{'key1'}{'key1.2'}='val1.2';
1
2
3
4
my %hash;
$hash{'key1'}={};
$hash{'key1'}{'key1.1'}='val1.1';
$hash{'key1'}{'key1.2'}='val1.2';
Quote...wenn schon ein Skalar oder Array da drin ist...
$hash{'key1'}={} and warn("Überschreibe \$hash{'key1'} mit einem Hash") if(exist($hash{'key1'}) and ref($hash{'key1'}) ne "HASH");
10 Einträge, 1 Seite |