HASH OF HASH Flashcards

1
Q

DECLARE HASH OF HASH

A

%hash = (
‘key’ => { ‘sub_key’ => ‘value}, …);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

LOOP THROUGH HASH OF HASH

A

for my $i (sort(keys %hash)) {
print $i;
for my $j (sort(keys %hash{$i})) {
print “$j:” %hash{$i}{$j};
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

CHECK INDIVIDUAL VALUE OF HASH OF HASH

A

$value = $hash{‘key’}{‘subkey’};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CHECK INDIVIDUAL VALUE OF HASH OF HASH

A

$value = $hash{‘key’}{‘subkey’};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ADD KEY VALUE PAIR

A

$hash{‘key’}{‘newksubkey’} = ‘newvalue’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DELETE SUBKEY

A

delete $hash{‘key’}{‘subkey’};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

UPDATE VALUE

A

$hash{‘key’}{‘subkeytobeupdated’} = ‘updatedvalue’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

IF EXISTS KEY

A

if (exists $hash{‘key’}){
#statement
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

IF EXISTS SUBKEY

A

if (exists $hash{‘key’}{‘subkey’}){
#statement
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly