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