Archive for December, 2009

Let’s write about something fun

Sunday, December 6th, 2009

No Perl, no technology, no pseudo-philosophy/pseudo-intellectual stuff and boring stuff I write about. Let me write about something fun. I’m flying back to Hong Kong tonight. I will get to see my girlfriend whom I haven’t seen since August 23rd.

And no one is more fun than her, so let’s write about her (and she never reads my blog, so I can be blunt :P ). She is really the light of my life; I’m the dull and boring guy, and she is the exciting one. If it weren’t for her, I couldn’t even finish this post since I’m no fun at all. And I think the phrase “better half” couldn’t be more suiting.

You know how when people grow older, they get more defensive, become less inquisitive, and lose that enthusiasm and purity that kids innately have? I know I am generalising but I believe it is a common phenomenon. Well she is still that naive, happy and uncorrupted child. It makes me smile just thinking about her. I wrote her a poem along the lines of being a “Rose in this concrete world”. Although she mentioned that she likes lavender :P

She has the most beautiful smile in the world; people just look at her and like her instantly. She is extremely good around people, and carries this aura of happiness. Am I exaggerating because she is my partner? Actually I think I am doing the opposite of exaggeration, since I don’t think I can capture her beauty with my writing.

Where ever she goes, she is THE child magnet. Kids love her, which is why I always encourage her to open a childcare. Her friends love her. But most importantly I love her. How did she end up with an over analysing, logical, soft spoken computer guy? Well that’s how relationships work; one half makes up what’s missing in the other half. And with that I end with this (I just couldn’t resist quoting :P ):

“I have lost count of the number of couples I have known in whom one partner’s apparent vices exactly correspond to the other’s virtues: bumptiousness to charm, noisiness to quietness, talking to listening, selfishness to grace, nastiness to kindness, meanness to generosity, closed to open, nasty to nice. I suppose people often look for a partner who can voice the parts of themselves they have difficulty in expressing.” – John Lanchester in Fragrant Harbour page 64.

OOP

Saturday, December 5th, 2009

Object orientated Perl! Boy, if there is one thing that I want to fully grasp, this would be it. So I spent time (yet again) reading perldoc perlboot. This would be the second time I’ve been through the beginner’s guide to OO Perl. Here’s are the key points (from memory which may be inaccurate):

  1. Packages are used to create “Classes”
  2. In each class, you have methods which operate on an object
  3. Methods are created by using Perl’s subroutines
  4. Methods from can be “inherited” from another class using the @ISA array
  5. The @ISA variable needs to be explicitly (if that’s the right word) declared, either using the full namespace or defined globally using “our”
  6. A constructor is a method used to create a specific instance
  7. An instance is a blessed Perl reference (be it a scalar, hash or array)
  8. The arrow invocation arrow “->” is used to specify a method for an object (i.e. $object->$method)
  9. When using “->” with an instance, the first argument passed to the method is the object
  10. When using “->” in the manner of Class->method, the first argument passed will be the class
  11. Interestingly (to me), when you use “->” with an instance, the method can still pick up the class from the instance

So by using these ideas, you can create classes with packages; within these classes you can create methods, i.e. the new method as the constructor which creates an instance of the object.

I think the best way to really learn OO Perl, is to start writing some. I will post my OO Perl exploits as they come along.