PERL:


PERL: - . 159


%surname = ( Mickey' => Mantle , "Babe => 'Ruth ), %first_name = reverse %surname, print $first_narae{"Mantle' , '\n", Mickey

%surname , :

('Mickey", "Mantle', "Babe', 'Ruth")

( , ("Babe", "Ruth", "Mickey", "Mantle' ), ­ ). :

('Ruth', "Babe", 'Mantle", 'Mickey')

:

('Ruth' => "Babe', 'Mantle" => 'Mickey')

5.2 foodfind. ­, , .

5.2. foodfind

#' /usr/bm/perl -w

# foodfind -

$given = shift @ARGV or die 'usage foodfind food_or_color\n ;

%color = (

'Apple ' => "red' ,


5.9. ࠠ 165

"Banana" => "yellow', "Lemon' => 'yellow", "Carrot" => 'orange'

%food = reverse %color,

if (exists $color{$given}) {

print "$given is a food with color $color{$given} \n',

>

if (exists $food{$given>) {

print '$food{$given} is a food with color $given \n' ; }

("Lemon' "Banana" ), ( , ). , Perl .

, ­ 5.7 , ­ :

# %food_color while (($food,$color) = each(%food_color)) { push(@{foods_with_color{$color}}, $food),




- -  - -  - -