@ekohl's suggestion is fine by me, but I'm not certain if using $title in a default parameter value is permitted or not (in the same way that other parameters can't be used, it's undefined behaviour, even if it appears to work).

@ehelms I meant having a default of "undef" is incorrect, since the variable is used in the exec without any thought to it being optional.  The "= undef" part should be removed, as it's a required parameter.