Learning Perl Objects, References amp;amp; Modules [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Learning Perl Objects, References amp;amp; Modules [Electronic resources] - نسخه متنی

Randal L. Schwartz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید














11.8 Exercise


The answers for all exercises can be found in Section A.10.


11.8.1 Exercise [30 min]


The Professor has to read a log file that looks like:

Gilligan: 1 coconut
Skipper: 3 coconuts
Gilligan: 1 banana
Ginger: 2 papayas
Professor: 3 coconuts
MaryAnn: 2 papayas
...

He wants to write a series of files, called
gilligan.info, maryann.info,
and so on. Each file should contain all the lines that begin with
that name. (Names are always delimited by the trailing colon.) At the
end, gilligan.info should start with:

Gilligan: 1 coconut
Gilligan: 1 banana

Now the log file is large, and the coconut-powered computer is not
very fast, so he wants to process the input file in one pass and
write all output files in parallel. How does he do it?

Hint: Use a hash, keyed by the castaway name, holding
IO::File objects for each output file. Create them
as necessary.



/ 199