PERL:


PERL: - . 162


# %food_color
%drink_color = ( Galliano => yellow ,

Mai Tai => blue ),

%substance_color = (),

while (($k, $v) = each %food_color) {

$substance_color{$k} = $v } while (($k, $v) = each %drmk_color) {

$substance_color{$k) = $v, }

while. :


168 5

foreach $substanceref (\%food_color, \%dnnk_color ) { while (($k, $v) = each %substanceref) { $substance_color{$k} = $v,

, :

foreach Ssubstanceref (\%food_color, \%drink_color ) { while (($k, $v) = each %substanceref) { if (exists $substance_color{$k}) {

print Warning $k seen twice Using the first definition \n , next, } $substance_color{$k} = $v,

­ :

@>all_colors{keys %new_colors} = values %new_colors,

, %new_colors. , .

> ---------------------------------------------------------------------------------------------

each perlfunc(l); 4.9.

5.11.

, , , .

keys , ­ .

@ = (), foreach (keys %hash1) {

push(@common, $_) if exists $hash2{$_}, } # ^common


5.12. ꠠ 169 ,

my @this_not_that = (), foreach (keys %hash1) {

push(@this_not_that, $_) unless exists $hash2{$_}, }




- -  - -  - -