perl.
. .
, ($ key1 $key2), () $key3. .
, , , - , - .
, %foo :
$foo{one}->{alpha}->{apple};
$foo{one}->{alpha}->{berry};
$foo{one}->{beta}->{cucumber};
$foo{one}->{beta}->{durian};
$foo{two}->{uno}->{eggplant};
$foo{two}->{uno}->{fig};
$foo{two}->{dos}->{guava};
$foo{two}->{dos}->{honeydew};
, -> , , -, . .
, . ?
-> . :
$foo{one}->{alpha};
$foo{one}->{beta};
$foo{two}->{uno};
$foo{two}->{dos};
, , , , . , , - , .
. , . , . , - , :
$foo{one};
$foo{two};
, , , . , , .
, - , , , .
- :
$person{$ssn}->{NAME}->{FIRST} = "Bob";
$person{$ssn}->{NAME}->{MI} = "Q.";
$person{$ssn}->{NAME}->{LAST} = "Smith";
Here I can go directly to the first, last and average initial value of each person. All I have to do is go through the various social security numbers:
for my $ssn ( sort keys %person ) {
say "My name is " . $person{$ssn}->{NAME}->{FIRST}
. " " . $person{$ssn}->{NAME}->{MI}
. " " . $person{$ssn}->{NAME}->{LAST};
}
source
share