March 2009 Archives

Palm PreI’m very stoked about the Palm Pre. Last night on Jimmy Falon’s talk show, Engadget editor Joshua Topolsky and “Jim” shared love for the forthcoming smartphone. See the video here.

Hey y’all, I’ve volunteered to teach in the Fedora Classroom this Saturday (7 Mar 2009). The Fedora Classroom is an IRC-based classroom environment.

So, at 3pm MST (22:00 UTC), anyone can participate by logging in to #fedora-classroom on irc.freenode.net and I, fozzmoo, will be doing a 1-hour presentation on Perl basics.

I’ve been digging through old presentations and workshops notes from when I used to do all day Perl workshops at USU for the USU Free Software and Linux Club to see what I can distill down into a 1-hour presentation. If there’s enough interest and response, we’ll see about turning this into a regular thing.

(Ryan Byrd)[http://www.ryanbyrd.net/techramble/] blogged recently with a (programming interview question)[http://www.ryanbyrd.net/techramble/2009/03/03/programming-interview-question-of-the-day/] that I thought I’d take a stab at in Perl.

The question is as follows:

  • when passed in a number that is evenly divisible by 3, return “wiz”
  • when passed in a number that is evenly divisible by 5, return “bang”
  • when passed in a number that is evenly divisible by both 3 and 5, return “wiz bang”
  • otherwise, return the number passed in

My solution exploits Perl’s list type to store potential output as a queue of sorts.

sub function {
    my $num = shift;
    my @output = ();
    unless($num % 3) {    push @output, "wiz"; }
    unless($num % 5 ) {    push @output, "bang"; }
    if(@output) {   return join ' ', @output; }
    return $num; 
}

About this Archive

This page is an archive of entries from March 2009 listed from newest to oldest.

February 2009 is the previous archive.

May 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.