Small Mosaic


Categories:

books
career
codinghorrors
comics
events
geekstuff
justdont
languages
languages/bash
linkshot
magazines
meta
misctech
movies
nottech
operatingsystems
operatingsystems/linux
operatingsystems/linux/debian
operatingsystems/solaris
paranoidadmin
perl
ruby
security
security/apache
security/tools
serversmells
sites
specifications
sysadmin
tools
tools/commandline
tools/firefox
tools/gui
tools/network
tools/online
tools/online/greasemonkey
unixdaemon

Archives:

April 20084
March 20081
February 20081
January 200815
August 20072
June 20079
May 20076
April 20078
March 200731
February 20073
January 200721
December 20061
November 20064
October 20066
September 200632
August 200617
July 200614
June 20069
May 200613
March 200611
February 200616
January 200611
December 20051
November 20056
October 200519
September 200525
August 200516
July 200516
June 200513
May 20052
April 200519
March 200531
February 200520
January 200531
December 200421
November 200430
October 200432
September 200418
August 20047
July 200414
June 20045

Tue, 01 Jan 2008

Perl 5.10 - My Favourite Three Features
Since the release of Perl 5.10 (back on 2007/12/18) there have been a fair few articles discussing all the shiny new features - including smart matching, a built-in switch and state variables but my favourite three haven't really received much coverage. So I'll add to the pile of blog posts.

First up is a tiny (from the outside anyway) change that may have the biggest impact of all the new features on my day to day perl - the display of the actual name of uninitialized variables.


# older perls
$ perl584 -we 'print $foo, "\n";'
Use of uninitialized value in print at -e line 1.

# perl 5.10
$ perl510 -we 'print $foo, "\n";'
Use of uninitialized value $foo in print at -e line 1.

From the perspective of someone who has to spend the occasional afternoon reading Apache errorlogs I really like this one.

Now we move on to stackable file tests; something I was surprised perl couldn't do when I first noticed it was missing years ago -


# older perls
...
if (-s $file && -r _ && -x _) {
  print "$file isn't zero length and is +rx\n";
}
...

# perl 5.10
...
if (-s -r -x $file) {
  print "$file isn't zero length and is +rx\n";
}
...

Lastly on my little list is named captures - instead of referencing $1 and $2 etc. you can now assign them names at the point of capture and then pull the values out of a hash at a later time -


# requires 5.10 or above. But not 6.

my %date;
my $sample_date = '20071225';

if ( $sample_date =~ /(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})/ ) {
  %date = %+;
}

say "The year is $date{'year'}";

While none of these are massive attention grabbing additions like the powerful smart matching, switch statement or say (one of those is not like the others ;)) they help make the day-to-day stuff a little more pleasant.

Bonus feature -


my $x;
my $default = 'foo';

$x = 0;
$x ||= $default; 

say "\$x is $x";

$x = 0;
$x //= $default;

say "\$x is $x";

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/01/01 11:59 | /perl | Permanent link to this entry | This entry + same date


New Day, New Year and New job - Well - Two out of Three
As of 6PM yesterday (or midnight - depending on how you interpret my employment contract) my current role is redundant and I'm no longer a member of the working world. It was a mostly good 28 months and I was lucky enough to work with some damn smart people.

This wasn't unexpected. Between the Register articles and a generously lengthened consultation period most of us were pretty sure we'd be on the market again soon. My initial plan was to take a couple of months off (it's been nearly five years since I had more than a week and a half off in a single block) but there is a permie job that sounds very cool and a short term contract I'm interested in (and should hear about today) so I may have to delay the skiving a little longer.

One of the nicer things to come out of this being over is that I can start getting involved in external projects again. I think I'll spend more time this year annoying the people writing some of the projects that should make up my tool chain over the next year or two. I still like Puppet and after a little playing around with Cobbler I quite like it. Especially if the "Debian breed" stuff works. Of course, this means I'll need to learn at least basic Ruby and Python so there goes that extended holiday I was going to take. Unless I lug a pile of books to the beach :)

Now to spend the day lazing around, recover from a late night and enjoy being a drain on society for a whole day. Happy New Year.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/01/01 11:01 | /career | Permanent link to this entry | This entry + same date


books career codinghorrors events geekstuff justdont languages/bash linkshot magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl ruby security security/apache security/tools serversmells sites specifications sysadmin tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey unixdaemon

Copyright © 2000-2005 Dean Wilson XML feed logo