Ewww, perl semantics

Ewww, perl semantics

Published on Jan 22, 2004, 1:47 PM1 min read
if ($var ne "mode")
 return errmsg("Mode not set");
return errmsg("Mode not set") if ($var ne "mode");
unless ($var eq "mode")
 return errmsg("Mode not set");
return errmsg("Mode not set") unless ($var eq "mode");

Whats the difference between those lines of code? (assuming i wrote them correctly) Absolutly nothing, other than your style.

That was one of my biggest pet peeve when working on code for them. There was always at least one code reviewer who tried to tell me my code was WRONG because I didn't pick the right style.

return errmsg("Mode not set") unless ($var eq "mode"); I agree with is the best one for readability (Return an error message unless $var is "mode").. Actually I don't think I do even agree with that anymore.. Thats like having instructions:

  1. Put peices of bed together
  2. Make sure to unscrew peice A first

Its just not how people naturally read instructions, you want them in order.

Unfortuatly, I have a desire to start working on Livejournal again. I think purely for selfish reasons, because I love working on projects that people actually use..

And the Livejournal Portal is so... overlooked.

I just have no interest in the code politics..

I guess I'll have to find new projects, or at least finish the ones I've started... like Dark Warriors.


Kristian: Hmm. I think you'd probably be an excellent person to discuss an idea I have with. I gotta give it a proper write-up, though, it's quite disjointed in my head right now.

Gavin: Sounds intreging and fun, and I'm oh so bored.

I've actually started to work on other projects tonight.

Gavin Mogan
Burnaby, BC, Canada

I'm Gavin.

I'm a tinker, maker, and software developer.

At home I code, game, hang out, all the cool non robot things to do.

Heavily involved with Jenkins open source, and will often submit PRs to random other projects.

I also play games, both board and video games and love to read.

You can usually find me on various services as halkeye.