Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
A short Perl example
#!/usr/bin/perl -pa
$_ = "$F[0] $F[-2]\n";


What does that Perl code do?

Although it's very short, it's also somewhat obscure, and my delegates yesterday were not at all sure that they would wish to be given code like this to maintain ... but then they admitted that they have seen things like this around ...

There are some Perl programmers who take what I feel is a perverse delight in writing their code as short as possible, even to the extent that it looses clarity; for sure, you should make good use of the Perl language and its facilities to avoid needless loops - use a grep in place of a foreach loop with a regular expression check and a push, and slurp a file into a list by all means rather that reading in through a while loop - but the above takes it just too far!

Oh - I asked you what it does, didn't I? It reads the file named on the command line in line by line, and prints out the first and next-to-last field on each line, throwing away the rest of the data.
(written 2008-07-30 00:11:42)

 
Associated topics are indexed under
P210 - Perl - Topicalization and Special Variables
P711 - An Introduction to Standards in Perl

Back to
Equality and looks like tests - Perl
Previous and next
or
Horse's mouth home
Forward to
Back from the future

Some other Articles
Old pictures and comparisons
Apache httpd, MySQL, PHP - installation procedure
Punting on the Cam
Back from the future
A short Perl example
Equality and looks like tests - Perl
Hot Courses - Perl
A future vision for Melksham
addslashes v mysql_real_escape_string in PHP
Bath - Melksham - Devizes. Bus route changes, new timetable
1770 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, 36 at 50 posts per page


This 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).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho