Archive for June, 2011:

Perl’s Join Function


Reading other people’s code can be quite revealing at times. Having recently started a new job, I get the daunting (… or delightful?) task of diving into unfamiliar, pre-existing code. A new experience for me, and one that has helped me grow much in the last couple months.
 
The Perl join( ) function is a perfect example.
 
In the past, I would manually loop through all the elements, concatenating the delimiter inside the loop.
 

Then I would chop( ) the last delimiter off the end, like so …

my @rray = qw(Joe Nancy Brett);
my $tring = “”;
 
foreach my $name (@rray) {
$tring .= $name.”,”;
}
 
chop($tring);

… when all along, the same job could have been executed with two lines.

my @rray = qw(Joe Nancy Brett);
my $tring = join(‘,’,@rray);

A little more time invested in manual reading might be well-spent. :~/

Tags: , ,

Leave a Comment

Stumbling Block to Marathon Training

True story :) This happened about the beginning of March this year. I couldn’t sit up for a few days, and when I finally could, it was painful. A couple months, and 10 pounds later, I’m finally able to run 5k distances without pain (and odd numbness of my middle toes on my right leg WTF?). I’m also motivated to get back into old hobbies again (peak-bagging/hiking, photography, etc). #wewt

Tags: , ,

Comments (3)