Recent posts on ν42:

Golfing a word count program

Most interesting Perl programs are not one-liners. They free the programmer from the drudgery of building up and tearing down commonly used data structures to enhance the programmer's ability to focus on the real problem. It is refreshing to see that C++ now feels that way as well. (more)

Can C++ become your new scripting language?

Containers that free the programmer from the burdens of manual memory management, algorithms, lambdas, and even autovivification! Is C++ becoming straightforward enough to use in daily programming tasks? (more)

Sending faxes using Perl on Windows

A minimal script to send a fax using Perl on Windows. Of course, this assumes your computer actually has a fax modem installed. If not, the RNX-56USB looks like it would do the job. It works on both Linux and Windows.

Can programmers do Statistics?

I have a feeling that most programmer types assume Stats is trivial because the arithmetic involved in most of the basic concepts they have occasion to use is trivial.

In reality, people who assume Stats is trivial share the same lack of understanding pretty much everyone else has about basic Stats concepts. For example, many of them seem to assume that significant test statistic, by itself, means something about the truth of a hypothesis, or that a high correlation coefficient between two variables means one causes the other, or one can reliably predict future values one using the future values of the other.

Windows does have symlinks

Since Vista, one can use the mklink command to create symlinks. mklink is rather cumbersome to use because Windows has no sudo (sudowin aside), but symlinks do exist, and they are pretty convenient once you create them … (more)

Highlight Perl source code using PPI::HTML

A recent Stackoverflow question introduced me to the PPI::HTML module which uses the amazing PPI module to parse Perl source code, and associate CSS classes with the various elements.

What if you wanted to produce a self-contained chunk of syntax-highlighted Perl without depending on external CSS or JavaScript? In that case, you can resort to a somewhat grungy technique I use when I am generating HTML email: Post process the HTML to replace classes on elements with style attributes.

How you average numbers matters

Every now and then, I end up having to explain to skeptical people why it matters how their programs treat the numbers they ingest. With IEEE 754 and doubles, people seem to think that one can just will nilly add a bunch of numbers and average them, and get reliably accurate results … (more)

It all boils down to stat vs fstat from MSVCRT on Windows

Last time, I had just noticed that my perl's stat $filename and stat $fh did not agree on the modification time of a given file.

This turns out to be due to a difference in the way the underlying system calls on Windows behave. (more)

Time zone insanity on Windows

A bit of time zone insanity on Windows causes a spurious test failure with Mojolicious. (mode)

Fixing an oversight in Math::Int64

stdint.h is included if we are compiling with MinGW, but not if we are compiling with a Microsoft compiler. There is a good reason for that: Visual Studio up to version 2010 did not include stdint.h.

But, I am building this with VS 2013, so things get messed up. (more)

Do you uuencode? pack 'u' does!

Uuencoding, which I first used over 25 years ago, and forgot about soon after I stopped using Eudora on Windows 3, can be used to include encoded binary data in the __DATA__ section of a Perl file. (more)

Include image data in the data section of your Perl script or module

This example shows how to do it without adding new dependencies to your project … (more)

Fixing malformed XML with Perl's XML::Parser

I have more experience than I would like to recount being in the middle of a data processing pipeline. I often have to acquire data sets which have been produced using deity knows what kind of COBOL written several decades ago, then passed through several layers to produce what seems to be the cool data format of recent times. Owing to the fact that I am both an economist and a developer, I am often also the end user of said data sets, so I have a vested interest in getting those data sets to usable shape. I have had to resort to using JScript on locked down Windows Servers to process awful lookup tables put together as if the largest hard drives were still 44 Mb Miniscribes.

Frequenly, you find yourself having jumped through 1600 bureaucratic steps to actually get access to the data, and the upstream is either unresponsive to constructive criticism, or worse. In these circumstances, it falls on you to fix others' mistakes, and keep things moving, because it is not your job, say, to enforce the XML standard. (more)

Hands off that constant

In this Stackoveflow question titled "How do I programatically construct constant name and use value of constant?", we have someone who wants to be able to construct names of constants and look up their values.

A Perl programmer knows that if you want to look up values based on string keys, you should use a hash. (more)

Trend analysis at the shallow end of the pool

I have always wondered why some people feel Perl has to suck for their choice of language to be valid. It looks like there are a bunch of people who just try to satisfy their need for approval by seeking what's most popular, and trying to hitch their wagon to that train. I do not know what they can gain by this, but they exist.

Yesterday, I noticed a post on HN which linked to a Google trends comparison of Perl and Python … more

Building libexpat and XML::Parser on Windows 8.1 64 bit using Visual Studio 2013

One of the two main stumbling blocks I have had to a really fulfilling experience with my self-built perls on Windows has been my failure to build libexpat, and libgd. … more

A Ubee nightmare: Maybe your cable modem is the problem after all

After another one of the Ubee replacements from Time Warner failed to even establish a connection after hours of trying, I decided, maybe I was right to be suspicious of the crappily constructed ugly thing that cannot sit straight.

I stopped by the local Walmart, and got myself the most reasonable looking cable modem among the three that were on the shelves: A ZOOM 5341J. … more

UTF-8 output in cmd.exe: perl 5 vs perl 6

I have mentioned before that there are some problems with UTF-8 output in cmd.exe with perl 5.

When I successfully built a perl 6 binary, I was excited to see it produce perfectly good UTF-8 output. … more

When bits don't stick: More portability bugs in Perl modules

The process of putting together the talk lead me to discover another two more of those pesky bugs due to platform differences in handling files. These are more interesting than the directory separator character style issues that I have been ranting about, mostly because of how hard they were to see just by looking at the code. I will submit patches, obviously, but my hope with these blog posts is to re-emphasize that these platform-specific differences do exist, whether we like it or not, and if more people are aware, fewer bugs will make it into CPAN modules in the first place. … more