in reply to unlink glob

The fix suggested (unlink glob("$prefix$runid.*") or ...) will only report an error if no files can be unlinked. If only some files cannot be unlinked, no error will be reported. You probably want

unlink $_ or print "Error removing file \"$_\": $!\n" for glob("$prefix$runid.*");

I also doubt $! is set properly, especially when processing multiple files.