Already figured it out (with help from perl -d)- the test is failing, and the list context is making that first argument disappear, whereupon 'xyz' becomes the test. ok( 0+($out =~ $expected),'xyz') does the right thing.