Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Wednesday, November 20, 2013

Time::Local

Time::Local's timelocal function is designed to be the reciprocal of localtime - which means it expects the same odd mix of 0- and 1-based numbers in the array you give it.

It departs from localtime conventions only in that it will interpret a year > 999 as a calendar year (it can do this, and still reciprocate localtime, because localtime isn't going to return a number that large in its year element until AD 2900, and the 1970-based seconds totals that time() returns are going to go tits up in 2038 anyway).

Warning: you positively should not attempt to use the localtime convention for years in subtracting 1900 from a 20th century date, because the resulting year < 100 will be interpreted as a year in the 20th or 21st centuries with a rolling century break. So this being 2013, 1940 - 1900 == 40 will be interpreted as 2040, which causes time() to blow up.

Wednesday, November 6, 2013

Perl capture group variables not reset

Perl has a 'feature' which means capture group variables ($1, $2 etc) are not reset if the match fails.

Apparently the only way to force a reset is to do a trivial match, eg "Brian D Foy's shift key is broken" =~ m/Brian D Foy/ .

Followers

Blog Archive