| |||||||||||
| |||||||||||
Perl, PHP or Python? No - Perl AND PHP AND Python!
"Which language is best for xxx task" I am often asked. And I'll listen to the questioner's description of his application, his background, and the sort of support he'll have at his place of coding before coming up with a suggestion. Never would I suggest he learn all three.
And yet, today, I found myself with a little task to do - it took me no more that a few minutes - and I used all three languages without even thinking about it. The task. A 900 Mbyte web log file - recording all the traffic from the last year at our First Great Western Customer Forum and a requirement to get some information out of it about the geographic spread of the visitors. 1. A little bit of PERL (the Practical Extraction and Reporting Language) to pull all the different IP addresses that have visited the site out of the file. #!/usr/bin/perl -na2. A PHP script - as we have the PHP / MaxMind routines easily accessible - to add the country of origin for each visitor to the data (that's right - PHP running from the command line!) <?php3. Another piece of Perl to count the number of visiting IP addresses from each country while (<DATA>) {4. and finally Interactive Python in place of a calculator to do some final statistical arithmetic on the results. OK - I'll admit it; I got caught miscoding once by the different format of foreach in Perl and PHP, but otherwise it all worked pretty well. If you want to see the information extracted by this process, look here. And, no, I'm not really proud of the beauty of my code; written to fulfill a quick one-off hacking job. If you think I've not given Python a fair run above, you're right. But then I have been using it all day as a notepad as I do my final personal tax calculations, with all the additions keyed in so I can go back and check my sums as I may need to over the next few days. That's code and numbers that I won't be sharing here, of course! (written 2008-01-20 21:18:56) Associated topics are indexed under Q777 - Object Orientation and General technical topics - Technology OverviewsQ904 - Object Orientation and General technical topics - Analysing a Programming Task G902 - Well House Consultants - Web site techniques, utility and visibility
Some other Articles
Python - formatting objectsPictures you can use - for free - from our library Keeping staff up to date on hotel room status Autovivification - the magic appearance of variables in Perl Perl, PHP or Python? No - Perl AND PHP AND Python! Summer Ball at Bowood - Saturday 12th July 2008 Buses from Well House Manor, Melksham, to Bath Handling Binary data (.gif file example) in Perl Extracting information from a file of records How not to write Perl? 1710 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||