Category Archives: Programming

Get DateTime in YYYY-mm-dd HH:MM:SS format using Perl

For many years I’ve been using the long process of obtaining everything from localtime(), adding 1900 to the year etc. etc. but I’ve just come across the method below, which uses strftime from the POSIX module. use POSIX;   my $DateTime = strftime "%F %T", localtime $^T; This gives you: 2006-10-02 02:06:07 Now that’s a [...]

“Object reference not set to an instance of an object.” when using OpenSubKey

Whilst using a working project on my new development machine, I came across an issue that stumped me for a while. Microsoft.Win32.Registry.LocalMachine.OpenSubKey(“subkey”).GetValue(“blah”) was failing with the error above, even though it worked perfectly previously and the key was clearly in the registry. After a bit of research I found it to be because I’m now [...]