| |||||||||||
| |||||||||||
The wonders of Perl
I was asked yesterday (and not for the first time) what my favourite programming language is - and I have to say that it depends on what I'm doing at the time. That's not a "political" answer in any way - as we choose to train only on languages that we're very happy indeed with. I've just had a little "exercise" to do. I have a list of place names in Mexico, and (on the following line) the dialling code for each of them within the country - for example Acapulco 74 Cancun 98 Celaya 461 Chihuahua 14 And I needed the data reformatted at one place per line, to include the extra digits for the international code too. Easy - the Perl program was just while (<>) { chop; /^\d/ and print "0052$_ $place\n"; /^[[:alpha:]]/ and $place = $_; } And the output produced: 005274 Acapulco 005298 Cancun 0052461 Celaya 005214 Chihuahua 005216 Ciudad Juarez 005267 Culiacan 00523 Guadalajara 005262 Hermosillo 0052112 La Paz 0052113 Loreto 0052678 Mazatlan 005299 Merida 005265 Mexicali 00525 Mexico City 00528 Monterrey 005222 Puebla 0052322 Puerto Vallarta 005248 San Luis Potosi 005212 Tampico 005266 Tijuana 005217 Torreon 005229 Veracruz 0052492 Zacatecas Mexico Telmex We're also often asked how we maintain so much information on this web site AND run courses every week (Tcl last week, Python next ...) and the answer is easy - by using Modern open source languages to provide us with helpful tools to do the job. I've used Perl for this page, and an hour or so ago I was adding data under a PHP page See also Topicalization in Perl - ideal for short data munging scripts Please note that articles in this section of our
web site were current and correct to the best of our ability when published,
but by the nature of our business may go out of date quite quickly. The
quoting of a price, contract term or any other information in this area of
our website is NOT an offer to supply now on those terms - please check
back via our main web site
Related Material
Perl - Topicalization and Special Variables resource index - Perl Solutions centre home page You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum. At Well House Consultants, we provide training courses on subjects such as Ruby, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site. |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||