Skip to Content
Programming PERL in the .NET Environment
book

Programming PERL in the .NET Environment

by Yevgeny Menaker, Michael Saltzman, Robert J. Oberg
September 2002
Intermediate to advanced content levelIntermediate to advanced
496 pages
10h
English
Addison-Wesley Professional
Content preview from Programming PERL in the .NET Environment

Useful Hash Examples

If you have not seen hashes before, you might be amazed at the places where they can be used. The following examples show some application areas where this data type is useful. Notice in these examples that the hashes are built dynamically in response to the requirements of the program. This is different from the %groups hash above, where that hash was initialized before accepting user input.

Counting Words in a File

This example demonstrates how to use a hash to count the frequency of words in a file. The strategy is to read lines from a file and split each line into its words. Then each word can be used as an index into a hash where the associated value can be the count for each word. Here is the code. See the folder

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Sams Teach Yourself Perl in 21 Days, Second Edition

Sams Teach Yourself Perl in 21 Days, Second Edition

Laura Lemay, Rafe Colburn
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 0130652067Purchase book