Perl Tutorials -Part 24 – Working with hashes

Posted on May 27, 2010. Filed under: Perl Tutorials |


#example of perl hash initiate.
%ingredients =
(
  protein => 'Chicken',
  starch => 'Rice',
  spice => 'Turmeric',
  vegetable => 'spinach'
);
#example of perl hash element referencing
print $ingredients{'protein'};
print "\n\n";

#another simple example of perl hash
%recordArtists =
(
    'Original nuttah' => 'Shy FX',
    'Kloaking Device' => 'DJ krust',
    'Cops Dont Like Us' => 'EZ Rollers'
);

print $recordArtists{'Kloaking Device'};

Output:
1
2
3
Chicken

DJ krust
Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: