I was fortunate enough to attend my very first in-person
Perl conference
this year in Las Vegas!
Ironically my first real exposure to Perl was almost 30 years (!!) ago when I read
Learning Perl
on a plane to Vegas!
It was great to finally meet so many wonderful people that I felt I already knew through using their software and watching conference talks from prior years. Here were the highlights of the conference for me.
Episode 294 of JS Party is titled Reports of Node’s death are greatly exaggerated and features two members of the Node Technical Steering Committee: Matteo Collina and James Snell. Their perspective on the project (and software development in general) was insightful, especially some of the challenges they face.
Time::Piece is my preferred perl module for handling dates. Here is how it can be used to convert between UTC and the local time, even for past dates which may have crossed the current daylight savings time status.
In an August 15 tweet, @iamdevloper, a very funny programmer-humor account, asked which technology you wouldn’t bother to learn over again: JavaScript, Regex, Kubernetes, or PHP. Never mind the completely obvious answer (if you aren’t in operations at Google, you probably don’t need Kubernetes), I was blown away on how many of the responders admitting to not knowing Regex.
The ack utility uses Perl regular expressions to efficiently search
source code, with smart defaults to limit the results to what you
expect.
One of the ways I use it is to search our Apache web log files. The
logs capture all requests, including ones for images, style sheets,
fonts, and javascript files. But usually I’m only interested in who
visited which web pages, including CGI scripts.
I’ve added a Bash function to my .bashrc file, acklog, that filters
out the extraneous files automatically:
# ack (grep) for scripts in apachefunctionacklog() {
ack "$@" | ack -v '\.(css|eot|gif|ico|jpe?g|js|png|svg|swf|webp|woff2?|xml)[? ]'
}
Our install process involves updating the CVS versions of individual files
on the staging and ultimately production servers. Web Operations is
responsible for manually updating the files listed on an electronic
install form.
After over ten years of this process, I finally realized that we could
automate this process, at least for the staging server. A cron script
polling a system mailbox every two minutes kicks off the process.
One feature of almost every modern commercial website is the location finder. Enter in a search address, and site displays the closest locations to it with the distances (as the crow flies).
I ran into a couple of peculiar bugs trying to calculate distances in SQL. Floating point math is never easy, and these are the issues I faced using our Microsoft SQL Server database.
At work, we use Microsoft SQL Server and IBM AS400 databases. Here’s
how I set our Linux boxes to allow them to connect to the databases
through ODBC. There are seperate instructions for the
Debian and Ubuntu (9.10 Karmic Koala) and Red Hat Enterprise Linux
(RHEL4 and RHEL5) distributions.
ODBC connections require several layers of software to work. The
bottom layer consists of the individual ODBC drivers for each
database system. Our top layer is the DBI/DBD interface for Perl.
In between these layers is the ODBC driver manager, which keeps
track of the DSN’s and their corresponding ODBC drivers.
Packages and Software to Install
Ubuntu Version (tested on 9.10 Karmic Koala)
Debian Version (“unstable” distribution)
We use unixODBC as our ODBC driver manager. First, install unixODBC:
NOTE: Perl’s DBD::ODBC module requires the developer’s version
of unixODBC, so install that one.
We’re having an issue with database queries to the iSeries AS400 through
Perl using DBI and DBD::ODBC. The issue occurs when the SQL statement
contains an outer join and the query returns rows with NULL columns:
my $sql_query = qq|select PRSK01, PSTA15
from TESTHA.POLMAST
left join TESTHA.P15POLDP
on POLC01 = PPOL15 where POLC01 = 003950136|;
# Execute the sql querymy $sth = $dbh->prepare( $sql_query )
ordie $sql_query, "<BR>\n", $DBI::errstr;
my $data = $dbh->selectall_arrayref( $sth, {Columns=>{}}, @sql_data )
ordie $sql_query, "<BR>\n", $sth->errstr;
The error returned is:
DBD::ODBC::db selectall_arrayref failed: st_fetch/SQLFetch (long truncated
DBI attribute LongTruncOk not set and/or LongReadLen too small) (SQL-HY000)
Here are a couple of tricks to remember when using jQuery’s tablesorter plugin with dynamic tables. These are tables that the user can add or delete from.
If the table begins empty (with no rows in <tbody>), you can’t
specify a default sort.
If there are no rows in the <tbody> section when the page is first
loaded, the sortList command will crash with a “parsers is undefined”
error.
Like the fellow that never read his car’s owner’s manual, I had never read the
entire
Perl FAQ.
I finally did it over the holidays, and these are some notes that I took.
Awhile back we had an issue where a coworker wanted to use one of my
Perl CGI scripts inside of her scripts, using the backticks method
to have it spit its output to the webpage. But for some reason, my
script refuse to recognize the arguments she was passing it. The
weird thing was, if we ran her script from the command line, everything
worked fine.
The issue is in the way CGI.pm detects whether it is being called from a
web browser or from the command line. It checks for the presence
of the REQUEST_METHOD environmental variable. If it is present,
CGI knows to get its arguments from the web browser.
For years, I’ve been searching for a suitable terminal emulator for
Cygwin, but nothing seemed as
polished or had enough features to pull me away from the boring
default.
I finally found the Holy Grail in a program I’ll call
Java Terminator.
The authors of this fine program just call it Terminator, but unfortunately a later Linux GNOME-based terminal emulator
of the same name
stole some of their thunder.
We have a Perl CGI script at work that acts as a proxy. It grabs a
pkcs12 digital certificate
file from an internal server and delivers it to a
user through his or her web browser. The pkcs12 file is in binary format.
Everything worked fine until we put the code on a new server. Suddenly, the
files downloaded by the web users were corrupted. We also began seeing the
following warning in the log files:
Recently, I was asked by my employer to write an Apache module. The module reads the requestor’s digital certificate and checks it against our database of active users. In this post, I’ll explain how to get started writing Apache modules, especially for Red Hat Enterprise Linux 5 (RHEL 5.2).
Splitting a Perl application into seperate files can be trickier than
doing it in other languages, like C or C++, but it is still an
important part of producing maintainable code.