| |||||||||||
| |||||||||||
Some one line Perl tips and techniques
I'm running a Perl Course this week ... a small group, so we can look at some very interesting constructs that I wouldn't normally cover / consider on a public course.
Comment out a block of code with an impossible condition if (1 == 0) { ....This is a great way to temporarily comment out a whole block of your code if you want to supress it for a while. Toggle a variable between two values $n = 3 - $n;If $n was one before the statement, it becomes 2, and vice versa. The constant you use (3 in this case) is simply the sum of the two values you wish to toggle between. Output an integer in binary printf ("%b",$value);sprintf and printf in Perl support the "b" formatter for binary - in addition to the more common "o" for Octal, "d" for decimal and "x" for hexadecimal. All of these techniques together ... # Some Perl TricksAnd when we run that: grahamellis$ perl ppa(written 2007-08-21 13:52:46) Associated topics are indexed under P103 - Perl - Variables and OperationsP202 - Perl Fundamentals P107 - Perl - Formatting Text P207 - Perl - File Handling
Some other Articles
Filtering and altering Perl lists with grep and mapTwo years of campaigning for a train service Business travel by train in the USA Tratum Technologies Some one line Perl tips and techniques What do people look for on a hotel web site? Callbacks - a more complex code sandwich Dates for Easter - 2008 to 2015 Good to be home Troy, up state New York 1638 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 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 | |||||||||||