Wednesday, June 18, 2008

Sweet, Sweet Perl

Behold my latest off-the-cuff answer to a problem of the day:

#!/usr/bin/perl -w
use strict;

my %lines;
my $all_lines;
my $line_num = 0;

$all_lines .= $_ while <DATA>;
$lines{$_} = 1 for split /\s+/,$all_lines;

while (<>) {
s/^/#/ if $lines{$line_num};
print $_;

169 170 171 172 173 174 175 176
314 315 316 317
320 321 322 323 324 325 326 327 328

Feel free to skip down to "Frank Muller" below if reading me geeking out isn't your bag. To save you the tedium of the complete history of what I was coding, I'll skip to the punchline: Thanks to the Sarbanes/Oxley act, brought about thanks to the assholes at Enron and MCI/Worldcom, I had a problem where I have to say how I want large changes made to a security access file 7 days from now, when I will be making daily small changes to the same file between now and then. This was granting emergency access to a service to people who really needed it, and undoing a larger set of access grants 7 days hence.

The solution? Identify line numbers in the access file to be commented out, and put all new daily changes to the file at the bottom, below all the lines to be commented. The script I came up with, pretty much off the cuff, shows the expressiveness of the Perl language. The line:

$all_lines .= $_ while <DATA>;

..iterates through all the text after __DATA__, an inline file handle, concatenating the text of each line to the string $all_lines. The line:

$lines{$_} = 1 for split /\s+/,$all_lines;

..splits the string $all_lines into a list of numbers separated by one or more whitespace characters (\s+), which means that a space and a line feed are both fine. For each item in that list, a hash element is added with a key of the number, and a value of 1.

The line:

s/^/#/ if $lines{$line_num}; the coup de grâce of the program. If the line number I'm currently on exists in the %lines hash, replace the first position of the line with a # sign (this "comments out" the line, making the security program ignore it). So in three small, but syntactically complex, lines, I've grabbed a list of lines to comment out, thrown it into a hash, and commented out lines in the config file whose line numbers appear in the hash.

Sweet, sweet Perl. Anyway, on to other stuff.

Frank Muller dead! I couldn't believe it! He apparently just died a couple weeks ago, after suffering for years after a motorcycle accident. This man, more than any other, kept my brain working in a time where I could have easily slipped into working minimum wage jobs my whole adult life. With my active brain, I slowly clawed my way to a good financial position, and now I get to live in a house I own, drive an SUV, and wear dress shirts every day... neener, neener, neener.

Frank Muller was an actor turned audiobook reader. When I spent 4 years flipping pizza, he was with me in my car several hours a night on deliveries, reading Moby Dick, Interview with the Vampire, Different Seasons (Stephen King's short stories under a psuedonym), 1984, and other books. I so enjoyed his voice and style of reading that I stopped looking for books I thought I would enjoy, and began looking for books read by him - a few were stinkers, but there were some pearls in there too that I never would have found if he hadn't been the reader.

After I exhausted most of Frank's work, I found other good readers, like Scott Brick, who did fantastic readings of Dune, Fahrenheit 451, Ender's Game, and a lot of Asimov. To this day I still hit the library a couple times a month looking for audiobooks to listen to on the ride to work, and I always pick up a couple before going on vacation for the car ride down.

And it all started with Frank, the fuel to keep my brain working when I needed it most. Thanks, Frank. I'll miss you.


My wife and I went for a mini-honeymoon over to Philadelphia for 3 days to check out some museums, included the Mutter museum of medical oddities (which fits our collective morbid sense of humor), and stopped into the wierd cultlike store IKEA to pick up some furniture and light fixtures.

I've got some pictures I took in the Philadelphia Museum of Art that I'll put up eventually as a Picasa album. Good stuff.

IKEA is interesting. They have an upstairs with apartments set up to show how you can design rooms using their furniture and art. Beside everything there are row and slot numbers for the pick-up area downstairs. Through the whole process, the staff leave you alone to go explore. I've heard some of the girls at work talk about how cool it is, and I think I'm going to have to agree.

Philly itself is a city I wouldn't want to settle down in. Too angry, too compact, too much hood. They have some good restaurants, though, and several theatres. Liberty and I went to see Les Miserables at a small theatre downtown, and it was a good production. Good place to visit, if you're good at ignoring the chaff.


My local over 30 team, the Raiderz, are 5-1-1 right now! We just had our 5th win Sunday, where my buddy Hemant from work contributed enough to keep us in the game when we were struggling. We were short subs, and all of us were pretty spent after the game. I think we probably would have lost if Hemant hadn't shown up and played as hard as he did.

My own performance was alright. I spent most of the game chasing down a guy with more endurance than me. Late in the game he finally got a good drive around me, I pushed him out to the corner, and he just snuck in a pass before I could block it, and the guy he passed it to scored. That put us up 5-3 in the 4th quarter, and we somehow came back and scored again before the end of the game making the final score 6-3. Lots of fun.

Thursday, Friday, and Saturday is the Columbus corporate challenge soccer tournament, where AEP is entered as 1 of 8 teams. I'm scheduled to play fullback on Thursday and Friday, and Saturday if we are in the top bracket, followed by my normal league game Sunday. I'm a little anxious about the whole ordeal. I'll have fun coming out and playing for AEP, where most people only know me as a code monkey, but I think playing 4 days in a row might just kill me.

Only one way to find out.


Stacey's away at horseback riding camp for the week, and will come back Friday evening, exhausted, sore, and hungry. I wrote her a pair of letters that should reach her before she leaves, saying what dads say to their girls - that I'm thinking about you, miss you, and hope you're out following your bliss. Her summer is a series of camps, and a few weeks with family out of state, with the punchline being the giant birthday party right before school starts. The party that I haven't even started planning for yet.


Still the best wife a man could ask for.

She's starting new classes this quarter, including Arabic! That gives me the chance to piggyback, trying my hand at deciphering a new alphabet and learning syntax rules of a non-romance language. woot!

I've met some of Liberty's extended family recently, at her grandfather's funeral. They all seemed to like me well enough, and most of them were smart and entertaining. Liberty's grandmother is in town until tonight, so Liberty and I went over to the house she's staying at with some other family for a goodbye dinner. It was simple and relaxed, little Scout played and was chatty with everyone, and I ended up orchestrating a family snapshot with Scout and Liberty slyly placed dead center.

I feel comfortable around her family. They don't seem to be demanding or judgmental, and I feel accepted when I'm around them.

Liberty has just installed some hair extensions to make her hair look long. It seemed like an odd choice to me, but I went with it, and I ended up enjoying putting them in for her. She couldn't put them in very well in the back of her head (since it requires visual feedback and some complex exchanges between hands), so I helped her put in about maybe 20 or 30 locks. I liked both getting to handle her hair for an extended time, and the playing with a new gadget aspect.


With the warmer weather, Liberty and I are enjoying taking Scout to parks in the afternoon. She's learning how to climb through the big-toys, getting brave on the larger slides, and talking to some of the other kids a little. The budding of social and physical intelligence is a wonderful thing to watch. This year should bring a lot of that for her, and I think I've most of the way recruited a part-time playmate from next door, little Marissa, who is 5 now.

Our personal relationship also got a lot better over the last couple of months. I passed from tolerated to accepted shortly before her mom and I got married, and now I feel like she enjoys having me around, doesn't ask me to leave so she an mom can play in private, and on rare occasions says that she loves me. Nice to hear, but 3 year olds are fickle, so I'm not basing my self worth on it just yet.

All is well.