Char or trout

Consider the joke told by Richard Stallman that I read in this article:

Once I was eating in Legal Sea Food and ordered arctic char. When it arrived, I looked for a signature, saw none, and complained to my friends, “This is an unsigned char. I wanted a signed char!” I would have complained to the waiter if I had thought he’d get the joke.

Until today, the word “char” had only one meaning to me. It was a computer term, which is used as a declaration of a character or string variable in some programming languages. Such as C, for example.

It turns out, that there is another meaning. Here is a quote from the dictionary for you:

also charr (n. pl. char or chars also charr or charrs)

Any of several fishes of the genus Salvelinus, especially the arctic char, related to the trout and salmon.

Wikipedia entries for those of you who want to learn more on this fishy subject: Salvelinus, Arctic char.

Analysis of two perl lines

Today I saw these two lines in one backup script that was written in perl:

my $d = (localtime())[6];
$d = $d=~/[067]/ ? 0 : $d % 2 + 1;

Does this look cryptic to you? Probably not. But I wanted to write something and thought that these two lines won’t be that obvious for everyone out there. So I decided to explain exactly what goes on.

Before I start, I have to say that these are not just any two random lines of perl code. These are very useful lines that provide a short and elegant solution to a rather common problem. Read on if you interested.

Continue reading Analysis of two perl lines