January 2023 Archives

Perl Testing in 2023

With my open source work, I've historically taken an approach which relies more on integration testing than unit testing, but with some of my newer projects, I've tried adopting principles from $paidwork and applying them to my free software.

This is a quick run-down of how I'm structuring my test suite in newer projects. It's likely that many of my existing projects will never adopt this structure, but some may.

Creating a Simple DSL in Perl

Let's look at the XSPF playlist format. It's a pretty simple XML-based file format.

  <?xml version="1.0" encoding="UTF-8"?>
  <playlist version="1" xmlns="http://xspf.org/ns/0/">
    <title>80's Music</title>
        <title>Take On Me</title>
        <title>Tainted Love</title>
        <creator>Soft Cell</creator>
        <title>Livin' on a Prayer</title>
        <creator>Bon Jovi</creator>

The full specification has a lot more details, but for now, we'll just use those elements.

If we are building a Perl application that needs to allow less experienced users to write playlists in Perl, it might be useful to define a domain-specific dialect of Perl for writing playlists.

Keeping Your Valuables Under Lock and Key

Consider the following fairly simple class, which creates a lookup object for month names:

package Local::MonthList { use experimental ="color:#333;backgr…

About Toby Inkster

user-pic I'm tobyink on CPAN, IRC and PerlMonks.