A Little Spring Scripting ------------------------- Spring is here, and all week long the winds were stripping cherry blossoms from the trees; a pink blizzard blowing past my office window. April is exam month and already the campus is notably quieter than before, though the Library is still packed with students hunkered over their laptops (and the occasional book). My administrative work has somewhat lightened up and there are more meeting-free gaps in my calendar. All signs pointing to the imminent arrival of summer session, when things get really quiet, and I shift into project mode. This week I was able to set aside a few hours to do a little scripting. In Perl, presumably because I'm a crusty irascible cantakerous old person full of stubborn ideas[1]. Well, it was the first scripting language I ever learned, when it was the New Hotness back in the mid-90s. And while poor Perl gets a bad rap for readability, not only has it served me well ever since, it has saved me from having to learn other, nuttier languages where even the most trivial spaces and tabs are Significant. ;-) It was pleasant to do some technical work for a change, though I couldn't help wondering whether my scripting skills (never better than adequate) had perhaps deteriorated somewhat from lack of use. Nevertheless, the problem seemed simple enough. Last fall, the Library installed some time-of-flight people-counting sensors over our main entrance. These post hourly reports of total entrances and exits via https to a PHP script that updates a database on one of our servers, from which our Data Analyst in turn produces nice reports in Power BI. However, at a certain point the sensors ceased communicating with the PHP script[2], and it took a while before someone noticed. Like, a while as in three months, which is a long gap in the data that's supposed to help justify why the Library needs to occupy as much space on campus as we do.[3] Fortunately, the sensors keep internal logs of their activity going back all the way to when we first installed them. So, all I had to do was download the sensor logs and load the missing data into the database. Simple, right? Shouldn't take more than a couple of hours, I thought. Except that that sensor logs recorded every exit and entry at the time of the event, and what I wanted was an hourly summary. Including hours when no sensor events were recorded, because the Library was closed. And allowing for the fact the sensors reset the counts to zero once per day, but did not adjust the reset time for daylight savings ... Anyhow, I won't recite further my Boring Litany of Problems, but suffice to say my initial two-hour time estimate was a tad optimistic. And on reflection, I think it's not so much my scripting that has grown rusty from lack of use, but rather a certain kind of problem-solving ability. Writing the 150 lines of Perl wasn't that hard. Figuring out how to reliably convert the logs into hourly reports was what took the time. I can't shake the feeling it wouldn't have taken me quite so long when I was in my programming prime. Back then, I could hyper-focus on these kinds of problems in a way that increasingly eludes me now, as ever more often my gaze is drawn from the monitor, to watch the petals drift in the wind. References and Notes -------------------- [1] http://www.wordnik.com/words/curmudgeon [2] Not coincidentally, the very same day the server was moved behind a load balancer. [3] Yes, I should have set up a cron job to monitor the database and alert me if it wasn't getting updates, but I honestly thought someone else was paying more attention to it than it turned out they were. Still, my bad. Sat Apr 12 17:21:44 PDT 2025