• Four short links: 19 May 2010 - Hiring Strategy, Data Catalogue Software, Web Frameworks, and Perl Lives

    Updated: 2010-05-31 22:14:46
    Google Hiring by the Lake Wobegon Strategy -- having just run some interviews myself, I recognise the wisdom in what they say. Another hiring strategy we use is no hiring manager. Whenever you give project managers responsibility for hiring for their own projects they'll take the best candidate in the pool, even if that candidate is sub-standard for the...

  • Syntax coloring utility

    Updated: 2010-04-21 00:09:17
    I often write HTML pages or documentation that includes code samples. When the code is presented this way, it's much easier to follow if it features syntax highlighting. I had found a script that could highlight Perl code, and then I realized I needed the same thing for C code as well. I've posted a new script on my web site that inserts HTML markup into source code files to provide colored syntax highlighting.

  • Perl in xkcd again

    Updated: 2010-04-11 21:25:36
    The web comic xkcd once again points out the importance of Perl:

  • A nice article from a recent student

    Updated: 2010-04-11 21:25:36
    At the end of each class, we always ask our students to fill out an evaluation form. There are two reasons for this: to find areas where we need to improve, and with the hope that they’ll put down some kind words that we can quote on the site in the testimonials page. [...]

  • Searching files with multi-line entries

    Updated: 2010-04-11 21:25:35
    Say that you have a file that looks something like this: 2008-01-02: first entry 2008-02-03: second entry on two lines here is the additional line 2008-03-04: third entry has three extra lines 2008-04-05: fourth entry has just one on line again If you need to search for all entries that have [...]

  • Sorting in Reverse Order

    Updated: 2010-04-11 21:25:35
    Say you have an array of names: @names=qw(Tom Dick Harry); If you wanted to sort these, you could just use a simple sort() command: @sorted=sort(@names); That uses alphabetical order for sorting by default. The sort criteria is not given, but you could get the same results by giving a longer version of the sort [...]

  • Finding the Biggest File

    Updated: 2010-04-11 21:25:34
    How do I find the biggest files under a directory? There are many ways to do this, but it isn’t always as easy as it sounds. First of all if the directory has no sub-directories, it’s easy. Just list the files sorted by size, which any operating system can do. But if there [...]

  • A Better Way to Slurp

    Updated: 2010-04-11 21:25:34
    In an earlier entry (was it really six years ago?) I talked about the usage of $/ and the -0 command-line option to Perl to change the input delimiter. But there’s another way to read in “slurp” mode that isn’t described there, the File::Slurp Perl module. File::Slurp provides a function read_file, which given a filename, [...]

  • Platform-Specific Perl

    Updated: 2010-04-11 21:25:33
    As an interpreted language, Perl scripts can generally be run unmodified on any platform. But there are situations where the differences between platforms make it necessary to test what platform you are running on and act accordingly. Say, for example, that you need to change permissions on a file. On Unix and related operating [...]

  • Ignorance is Bliss – non-memorizing parentheses

    Updated: 2010-04-11 21:25:33
    One of regular expressions’ most useful features is memorization. To do this, just put parentheses around part of your expression and the result will be memorized: my($name) = /hello, (\w+)/ In this example, we look in $_ for the word “hello” followed by a comma, space, and a word. Since the word, \w+, has parentheses [...]

  • Dates in Perl: Hawaiian Vacation Planning

    Updated: 2010-04-11 21:25:32
    Since we’re starting a new year, let’s look at handling dates in Perl. Let’s say the user enters a date and you want to check if it’s between a particular range of start/end dates. In particular, let’s say you want to go to Hawaii and your kids are in school for the spring semester from [...]

  • Finding the Largest File in a Directory

    Updated: 2010-04-11 21:25:31
    Here’s an easy way to find the largest file in a directory. First, open the directory to read the list of file names in it. opendir DIR, $directory or die "Error reading $directory: $!\n"; Then, read the file names and sort according to size. my @sorted = [...]

Current Feed Items | Previous Months Items

Apr 2010 | Mar 2010 | Feb 2010 | Jan 2010 | Dec 2009 | Nov 2009