Perl report Exercise-Example 1

Source: Internet
Author: User

51 Leisure, read a Perl instance of the Fine Solution (4th edition) of the ebook, this is the last example of the 19th chapter. Practice practiced hand to reward yourself for learning the process of knowledge.


The following source file is the file to be formatted:

$ cat xxx exotic liquids:charlotte cooper: (171)  555-2222New Orleans  Cajun delights:shelley burke: (+)  555-4822grandma kelly ' s homestead:regina  Murphy: (313)  555-5735tokyo traders:yoshi nagase: ( 3555-5011Cooperativa de ) quesos  ' Las cabras ': Antonio del valle saavedra: (98)  598 76 54mayumi ' s: Mayumi ohno: ( 431-7877PAVLOVA, LTD.:I) An devling: ( 444-2343specialty biscuits, ltd).:P Eter wilson: (161)  555-4448PB  knsckebrod ab:lars peterson:031-987 65 43refrescos americanas ltda:carlos  diaz: (one)  555 4640heli snwaren gmbh & co. kg:petra winkler: ( 010)  9984510plutzer lebensmittelgromsrkte ag:martin bein: (069)  992755Nord-Ost-Fisch  handelsgesellschaft mbh :sven petersen: (04721)  8713FORmaggi fortini s.r.l.:elio rossi: (0544)  60323norske meierier:beate vileid: (0) 2-953010bigfoot breweries:cheryl saylor: (503)  555-9931Svensk Sjofoda AB:Michael  Bjorn:08-123 45 67aux joyeux eccltsiastiques:guylfne nodier: (1)  03.83.00.68  new england seafood cannery:robb merchant: (617)  555-3267leka trading: Chandra leka:555-8787lyngbysild:niels petersen:43844108zaanse snoepfabriek:dirk luchte: ( 12345)  1212karkki oy:anne heikkonen: (953)  10956g ' Day, mate:wendy mackenzie: (02)  555-5914ma maison:jean-guy lauzon: (514)  555-9022pasta buttini s.r.l.:giovanni  giudici: (089)  6547665escargots nouveaux:marie delamare:85.57.00.07gai pgturage: Eliane noz:38.76.98.06forots d ' Trables:chantal goulet: (514)  555-2955


This file is the code file that you wrote:

$ cat example19.pl open (fh,  "<xxx")  or die  "Can" t open xxx:  $!\n "; $headline  = " + " . "-" x 12 . " + " . "-" x  40 .  "+" .  "-"  x 28 .  "+"  .  "-"  x 17 .  " + "; $field 1 = " > " x 9; $field 2 = " < " x 37; $field 3 = " <  x 25; $field 4 =  <  x 14; $format _top = qq (format stdout_ top = $headline | supplierid | companyname                              | contactname                 | phone           | $headline.); $format  = qq (Format stdout =| \@ $field 1 | \@ $field 2 | \@ $field 3 | \@ $field 4 |  \$.,      \ $compayname,  \ $contactname,  \ $phone.); eval  $format _top;eval  $format;while  (<FH>)  {     ($compayname,   $contactname,  $phone)  = split (/:/);     write;} Close (FH);p rint  $headline,  "\ n";


This is the result after the run:

$ perl example19.pl+------------+----------------------------------------+-------------------------- --+-----------------+| supplierid | companyname                              | contactname                 | phone           |+------------ +----------------------------------------+----------------------------+-----------------+|           1 | Exotic Liquids                           | charlotte cooper           |   (171)  555-2222  | |           2 | New Orleans Cajun  delights             | shelley  burke              |  ( ) 555-4822  | |           3 | grandma kelly ' S Homestead               | regina murphy               |  (313)  555-5735   | |           4 | Tokyo Traders                            | yoshi nagase               |  ( 3555-5011  |) |           5 | cooperativa de quesos   ' Las cabras '      | antonio del valle saavedra |   (98)  598 76 54  | |           6 | mayumi ' s                                 | Mayumi Ohno                 |  ( 431-7877   |) |           7 | Pavlova, Ltd.                           | ian devling                 |  ( 444-2343   |) |           8 | specialty biscuits, ltd.                | Peter  wilson               |  (161)  555-4448  | |           9 | PB KnSckebrod AB                         | Lars Peterson               | 031-987 65 43   | |          10 | refrescos americanas ltda               | Carlos Diaz                 |  (one)  555 4640   | |          11 | Heli Snwaren GmbH &  co. kg             | petra  Winkler              |  (010)  9984510   | |          12 | Plutzer LebensmittelgromSrkte  ag       | martin bein                 |  (069)  992755    | |           13 | nord-ost-fisch handelsgesellschaft mbh  | Sven Petersen               |  (04721)  8713    | |          14 | Formaggi Fortini s.r.l.                 | Elio  rossi                 |   (0544)  60323    | |          15 | Norske Meierier                          | Beate Vileid                |  (0)2-953010     | |          16 | Bigfoot Breweries                        | Cheryl Saylor               |  (503)  555-9931  | |          17 | Svensk Sjofoda AB                        | Michael Bjorn               | 08-123 45 67    | |          18 | aux joyeux eccltsiastiques              | guylfne nodier             |  (1)   03.83.00.68 | |          19 | New England Seafood  cannery            | robb merchant               |  (617)  555-3267   | |          20 | Leka Trading                             | Chandra Leka                | 555-8787        | |          21 | Lyngbysild                               | Niels Petersen              | 43844108        | |          22 | Zaanse Snoepfabriek                     |  Dirk Luchte                 |  (12345)  1212    | |          23 | Karkki Oy                                | anne heikkonen             |  (953)  10956     | |          24 | g ' day, mate                              | Wendy Mackenzie             |  ( 555-5914   |) |          25 | Ma Maison                                | Jean-Guy Lauzon             |  (514)  555-9022  | |          26 | pasta buttini s.r.l.                    | Giovanni Giudici            |  (089)  6547665   | |          27 | Escargots Nouveaux                      |  Marie Delamare             |  85.57.00.07     | |          28 | Gai pGturage                             | Eliane Noz                  | 38.76.98.06     | |          29 | forots d ' Trables                         | Chantal Goulet              |  (514)  555-2955  |+------------+----------------------------------------+---------- ------------------+-----------------+


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/4E/wKiom1VE5SyyNwyyAAcqTMr_JH0064.jpg "title=" Perl_ Picture_line.png "alt=" Wkiom1ve5syynwyyaacqtmr_jh0064.jpg "/>



This article is from the "Tiandaochouqin" blog, make sure to keep this source http://lavenliu.blog.51cto.com/5060944/1641337

Perl report Exercise-Example 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.